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? */
31 /* Is the array local to the scop? */
35 /* For each index i, array->bound[i] specialized to the current kernel. */
36 struct gpu_local_array_info
{
37 isl_pw_aff_list
*bound
;
43 struct ppcg_scop
*scop
;
45 /* Set of parameter values */
48 /* All read accesses in the entire program */
51 /* All write accesses in the entire program */
54 /* Uninitialized data elements (or an overapproximation) */
55 isl_union_set
*copy_in
;
57 /* Array of statements */
59 struct gpu_stmt
*stmts
;
62 struct gpu_array_info
*array
;
65 enum ppcg_kernel_access_type
{
71 enum ppcg_kernel_stmt_type
{
77 /* Instance specific information about an access inside a kernel statement.
79 * type indicates whether it is a global, shared or private access
80 * array is the original array information and may be NULL in case
81 * of an affine expression
82 * local_array is a pointer to the appropriate element in the "array"
83 * array of the ppcg_kernel to which this access belongs. It is
84 * NULL whenever array is NULL.
85 * local_name is the name of the array or its local copy
86 * index is the sequence of local index expressions
88 struct ppcg_kernel_access
{
89 enum ppcg_kernel_access_type type
;
90 struct gpu_array_info
*array
;
91 struct gpu_local_array_info
*local_array
;
93 isl_ast_expr_list
*index
;
96 /* Representation of special statements, in particular copy statements
97 * and __syncthreads statements, inside a kernel.
99 * type represents the kind of statement
102 * for ppcg_kernel_copy statements we have
104 * read is set if the statement should copy data from global memory
105 * to shared memory or registers.
107 * index expresses the array element that needs to be copied as a "call"
109 * local_index expresses the corresponding element in the tile
111 * array refers to the original array being copied
112 * local_array is a pointer to the appropriate element in the "array"
113 * array of the ppcg_kernel to which this copy access belongs
116 * for ppcg_kernel_domain statements we have
118 * stmt is the corresponding input statement
120 * n_access is the number of accesses in stmt
121 * access is an array of local information about the accesses
123 struct ppcg_kernel_stmt
{
124 enum ppcg_kernel_stmt_type type
;
130 isl_ast_expr
*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_size reflects the effect grid size.
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.
183 isl_multi_pw_aff
*grid_size
;
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 ppcg_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
);