5 #include "cuda_common.h"
6 #include "clast_printer.h"
7 #include "ppcg_options.h"
10 struct cuda_info cuda
;
11 struct clast_printer_info code
;
12 struct clast_printer_info kernel_code
;
13 struct clast_printer_info stmt_code
;
16 struct ppcg_options
*options
;
19 struct pet_scop
*scop
;
21 /* Set of parameter values */
24 /* tile, grid and block sizes for each kernel */
27 /* Uninitialized data elements (or an overapproximation) */
28 isl_union_set
*copy_in
;
30 /* All read accesses in the entire program */
33 /* All write accesses in the entire program */
36 /* Array of statements */
38 struct cuda_stmt
*stmts
;
41 struct cuda_array_info
*array
;
43 /* Identifier of current kernel. */
46 /* First tile dimension. */
48 /* Number of tile dimensions. */
50 /* Number of initial parallel loops among tile dimensions. */
53 /* Number of dimensions determining shared memory. */
56 /* Number of rows in the untiled schedule. */
58 /* Number of rows in the tiled schedule. */
60 /* Number of rows in schedule after tiling/wrapping over threads. */
63 /* Global untiled schedule. */
65 /* Local (per kernel launch) tiled schedule. */
66 isl_union_map
*tiled_sched
;
67 /* Local schedule per shared memory tile loop iteration. */
68 isl_union_map
*local_sched
;
69 /* Domain of the current statement (within print_statement). */
72 /* Position of first parameter corresponding to shared tile loop
75 unsigned first_shared
;
76 /* Local tiled schedule projected onto the shared tile loops and
77 * the loops that will be wrapped over the threads,
78 * with all shared tile loops parametrized.
80 isl_union_map
*shared_sched
;
81 /* Projects out the loops that will be wrapped over the threads
84 isl_union_map
*shared_proj
;
86 /* A map that takes the range of shared_sched as input,
87 * wraps the appropriate loops over the threads and then projects
90 isl_map
*privatization
;
92 /* A map from the shared memory tile loops and the thread indices
93 * (as parameters) to the set of accessed memory elements that
94 * will be accessed through private copies.
96 isl_union_map
*private_access
;
98 /* The schedule for the current private/shared access
99 * (within print_private_access or print_shared_access).
102 /* The array reference group corresponding to copy_sched. */
103 struct cuda_array_ref_group
*copy_group
;
104 /* copy_group->private_bound or copy_group->shared_bound */
105 struct cuda_array_bound
*copy_bound
;
107 /* First loop to unroll (or -1 if none). */
112 /* Note: in the input file, the sizes of the grid and the blocks
113 * are specified in the order x, y, z, but internally, the sizes
114 * are stored in reverse order, so that the last element always
115 * refers to the x dimension.
122 __isl_give isl_set
*add_context_from_str(__isl_take isl_set
*set
,
124 void collect_array_info(struct cuda_gen
*gen
);
125 void print_host_code(struct cuda_gen
*gen
);
126 void clear_cuda_gen(struct cuda_gen
*gen
);
128 int cuda_pet(isl_ctx
*ctx
, struct pet_scop
*scop
, struct ppcg_options
*options
,