5 #include "ppcg_options.h"
7 struct gpu_array_info
{
13 /* Name of the array. */
15 /* Extent of the array that needs to be copied. */
17 /* Number of indices. */
19 /* For each index, a bound on "extent" in that direction. */
22 /* All references to this array; point to elements of a linked list. */
24 struct gpu_stmt_access
**refs
;
26 /* The reference groups associated to this array. */
28 struct gpu_array_ref_group
**groups
;
30 /* For scalars, is this scalar read-only within the entire program? */
33 /* Is the array local to the scop? */
37 /* For each index i, array->bound[i] specialized to the current kernel. */
38 struct gpu_local_array_info
{
39 isl_pw_aff_list
*bound
;
45 struct ppcg_scop
*scop
;
47 /* Set of parameter values */
50 /* All read accesses in the entire program */
53 /* All write accesses in the entire program */
56 /* Set of array elements that need to be copied in. */
57 isl_union_set
*copy_in
;
58 /* Set of array elements that need to be copied out. */
59 isl_union_set
*copy_out
;
61 /* Array of statements */
63 struct gpu_stmt
*stmts
;
66 struct gpu_array_info
*array
;
69 enum ppcg_kernel_access_type
{
75 enum ppcg_kernel_stmt_type
{
81 /* Instance specific information about an access inside a kernel statement.
83 * type indicates whether it is a global, shared or private access
84 * array is the original array information and may be NULL in case
85 * of an affine expression
86 * local_array is a pointer to the appropriate element in the "array"
87 * array of the ppcg_kernel to which this access belongs. It is
88 * NULL whenever array is NULL.
89 * local_name is the name of the array or its local copy
90 * index is the sequence of local index expressions
92 struct ppcg_kernel_access
{
93 enum ppcg_kernel_access_type type
;
94 struct gpu_array_info
*array
;
95 struct gpu_local_array_info
*local_array
;
97 isl_ast_expr_list
*index
;
100 /* Representation of special statements, in particular copy statements
101 * and __syncthreads statements, inside a kernel.
103 * type represents the kind of statement
106 * for ppcg_kernel_copy statements we have
108 * read is set if the statement should copy data from global memory
109 * to shared memory or registers.
111 * index expresses the array element that needs to be copied as a "call"
113 * local_index expresses the corresponding element in the tile
115 * array refers to the original array being copied
116 * local_array is a pointer to the appropriate element in the "array"
117 * array of the ppcg_kernel to which this copy access belongs
120 * for ppcg_kernel_domain statements we have
122 * stmt is the corresponding input statement
124 * n_access is the number of accesses in stmt
125 * access is an array of local information about the accesses
127 struct ppcg_kernel_stmt
{
128 enum ppcg_kernel_stmt_type type
;
134 isl_ast_expr
*local_index
;
135 struct gpu_array_info
*array
;
136 struct gpu_local_array_info
*local_array
;
139 struct gpu_stmt
*stmt
;
142 struct ppcg_kernel_access
*access
;
147 /* Representation of a local variable in a kernel.
149 struct ppcg_kernel_var
{
150 struct gpu_array_info
*array
;
151 enum ppcg_kernel_access_type type
;
156 /* Representation of a kernel.
158 * id is the sequence number of the kernel.
160 * the first n_block elements of block_dim represent the size of the block.
162 * grid_size reflects the effect grid size.
164 * context is a parametric set containing the values of the parameters
165 * for which this kernel may be run.
167 * arrays is the set of accessed array elements.
169 * space is the schedule space of the AST context. That is, it represents
170 * the loops of the generated host code containing the kernel launch.
172 * n_array is the total number of arrays in the input program and also
173 * the number of element in the array array.
174 * array contains information about each array that is local
175 * to the current kernel. If an array is not ussed in a kernel,
176 * then the corresponding entry does not contain any information.
187 isl_multi_pw_aff
*grid_size
;
190 isl_union_set
*arrays
;
195 struct gpu_local_array_info
*array
;
198 struct ppcg_kernel_var
*var
;
203 int gpu_array_is_scalar(struct gpu_array_info
*array
);
204 int gpu_array_is_read_only_scalar(struct gpu_array_info
*array
);
206 struct gpu_prog
*gpu_prog_alloc(isl_ctx
*ctx
, struct ppcg_scop
*scop
);
207 void gpu_prog_free(struct gpu_prog
*prog
);
209 __isl_give isl_ast_node
*generate_gpu(isl_ctx
*ctx
, struct gpu_prog
*prog
,
210 struct ppcg_options
*options
);