7 #include "ppcg_options.h"
9 struct gpu_array_info
{
15 /* Name of the array. */
17 /* Extent of the array that needs to be copied. */
19 /* Number of indices. */
21 /* For each index, a bound on "extent" in that direction. */
24 /* All references to this array; point to elements of a linked list. */
26 struct gpu_stmt_access
**refs
;
28 /* The reference groups associated to this array. */
30 struct gpu_array_ref_group
**groups
;
32 /* For scalars, is this scalar read-only within the entire program? */
35 /* Is the array local to the scop? */
39 /* For each index i, array->bound[i] specialized to the current kernel. */
40 struct gpu_local_array_info
{
41 isl_pw_aff_list
*bound
;
47 struct ppcg_scop
*scop
;
49 /* Set of parameter values */
52 /* All read accesses in the entire program */
55 /* All write accesses in the entire program */
58 /* Set of array elements that need to be copied in. */
59 isl_union_set
*copy_in
;
60 /* Set of array elements that need to be copied out. */
61 isl_union_set
*copy_out
;
63 /* Array of statements */
65 struct gpu_stmt
*stmts
;
68 struct gpu_array_info
*array
;
71 enum ppcg_kernel_access_type
{
77 enum ppcg_kernel_stmt_type
{
83 /* Instance specific information about an access inside a kernel statement.
85 * type indicates whether it is a global, shared or private access
86 * array is the original array information and may be NULL in case
87 * of an affine expression
88 * local_array is a pointer to the appropriate element in the "array"
89 * array of the ppcg_kernel to which this access belongs. It is
90 * NULL whenever array is NULL.
91 * local_name is the name of the array or its local copy
92 * index is the sequence of local index expressions
94 struct ppcg_kernel_access
{
95 enum ppcg_kernel_access_type type
;
96 struct gpu_array_info
*array
;
97 struct gpu_local_array_info
*local_array
;
99 isl_ast_expr_list
*index
;
102 /* Representation of special statements, in particular copy statements
103 * and __syncthreads statements, inside a kernel.
105 * type represents the kind of statement
108 * for ppcg_kernel_copy statements we have
110 * read is set if the statement should copy data from global memory
111 * to shared memory or registers.
113 * index expresses the array element that needs to be copied as a "call"
115 * local_index expresses the corresponding element in the tile
117 * array refers to the original array being copied
118 * local_array is a pointer to the appropriate element in the "array"
119 * array of the ppcg_kernel to which this copy access belongs
122 * for ppcg_kernel_domain statements we have
124 * stmt is the corresponding input statement
126 * n_access is the number of accesses in stmt
127 * access is an array of local information about the accesses
129 struct ppcg_kernel_stmt
{
130 enum ppcg_kernel_stmt_type type
;
136 isl_ast_expr
*local_index
;
137 struct gpu_array_info
*array
;
138 struct gpu_local_array_info
*local_array
;
141 struct gpu_stmt
*stmt
;
144 struct ppcg_kernel_access
*access
;
149 /* Representation of a local variable in a kernel.
151 struct ppcg_kernel_var
{
152 struct gpu_array_info
*array
;
153 enum ppcg_kernel_access_type type
;
158 /* Representation of a kernel.
160 * id is the sequence number of the kernel.
162 * the first n_block elements of block_dim represent the effective size
165 * grid_size reflects the effective grid size.
167 * context is a parametric set containing the values of the parameters
168 * for which this kernel may be run.
170 * arrays is the set of accessed array elements.
172 * space is the schedule space of the AST context. That is, it represents
173 * the loops of the generated host code containing the kernel launch.
175 * n_array is the total number of arrays in the input program and also
176 * the number of element in the array array.
177 * array contains information about each array that is local
178 * to the current kernel. If an array is not ussed in a kernel,
179 * 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
);