5 #include "ppcg_options.h"
7 struct gpu_array_info
{
13 /* Name of the array. */
15 /* Number of indices. */
17 /* For each index, a bound on the array in that direction. */
20 /* All references to this array; point to elements of a linked list. */
22 struct gpu_stmt_access
**refs
;
24 /* The reference groups associated to this array. */
26 struct gpu_array_ref_group
**groups
;
28 /* For scalars, is this scalar read-only within the entire program? */
32 /* For each index i, array->bound[i] specialized to the current kernel. */
33 struct gpu_local_array_info
{
34 isl_pw_aff_list
*bound
;
40 struct pet_scop
*scop
;
42 /* Set of parameter values */
45 /* All read accesses in the entire program */
48 /* All write accesses in the entire program */
51 /* Uninitialized data elements (or an overapproximation) */
52 isl_union_set
*copy_in
;
54 /* Array of statements */
56 struct gpu_stmt
*stmts
;
59 struct gpu_array_info
*array
;
62 enum ppcg_kernel_access_type
{
68 enum ppcg_kernel_stmt_type
{
74 /* Instance specific information about an access inside a kernel statement.
76 * type indicates whether it is a global, shared or private access
77 * array is the original array information and may be NULL in case
78 * of an affine expression
79 * local_array is a pointer to the appropriate element in the "array"
80 * array of the ppcg_kernel to which this access belongs. It is
81 * NULL whenever array is NULL.
82 * local_name is the name of the array or its local copy
83 * index is the sequence of local index expressions
85 struct ppcg_kernel_access
{
86 enum ppcg_kernel_access_type type
;
87 struct gpu_array_info
*array
;
88 struct gpu_local_array_info
*local_array
;
90 isl_ast_expr_list
*index
;
93 /* Representation of special statements, in particular copy statements
94 * and __syncthreads statements, inside a kernel.
96 * type represents the kind of statement
99 * for ppcg_kernel_copy statements we have
101 * read is set if the statement should copy data from global memory
102 * to shared memory or registers.
104 * domain is the (parametric) domain of index and local_index
106 * index expresses the array element that needs to be copied in terms
108 * local_index expresses the corresponding element in the tile
110 * array refers to the original array being copied
111 * local_array is a pointer to the appropriate element in the "array"
112 * array of the ppcg_kernel to which this copy access belongs
115 * for ppcg_kernel_domain statements we have
117 * stmt is the corresponding input statement
119 * n_access is the number of accesses in stmt
120 * access is an array of local information about the accesses
122 struct ppcg_kernel_stmt
{
123 enum ppcg_kernel_stmt_type type
;
129 isl_pw_multi_aff
*index
;
130 isl_pw_multi_aff
*local_index
;
131 struct gpu_array_info
*array
;
132 struct gpu_local_array_info
*local_array
;
135 struct gpu_stmt
*stmt
;
138 struct ppcg_kernel_access
*access
;
143 /* Representation of a local variable in a kernel.
145 struct ppcg_kernel_var
{
146 struct gpu_array_info
*array
;
147 enum ppcg_kernel_access_type type
;
152 /* Representation of a kernel.
154 * id is the sequence number of the kernel.
156 * the first n_block elements of block_dim represent the size of the block.
158 * grid contains the values of the block ids.
160 * context is a parametric set containing the values of the parameters
161 * for which this kernel may be run.
163 * arrays is the set of accessed array elements.
165 * space is the schedule space of the AST context. That is, it represents
166 * the loops of the generated host code containing the kernel launch.
168 * n_array is the total number of arrays in the input program and also
169 * the number of element in the array array.
170 * array contains information about each array that is local
171 * to the current kernel. If an array is not ussed in a kernel,
172 * then the corresponding entry does not contain any information.
186 isl_union_set
*arrays
;
191 struct gpu_local_array_info
*array
;
194 struct ppcg_kernel_var
*var
;
199 int gpu_array_is_scalar(struct gpu_array_info
*array
);
200 int gpu_array_is_read_only_scalar(struct gpu_array_info
*array
);
202 struct gpu_prog
*gpu_prog_alloc(isl_ctx
*ctx
, struct pet_scop
*scop
);
203 void gpu_prog_free(struct gpu_prog
*prog
);
205 __isl_give isl_set
*add_context_from_str(__isl_take isl_set
*set
,
208 __isl_give isl_ast_node
*generate_gpu(isl_ctx
*ctx
, struct gpu_prog
*prog
,
209 struct ppcg_options
*options
);