isl_ast_build_ast_from_schedule: fix unrolling corner case
[isl.git] / isl_options.c
bloba5c6f6608c5b265f361e8828c0e0fda6b4577dcf
1 /*
2 * Copyright 2008-2009 Katholieke Universiteit Leuven
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege, K.U.Leuven, Departement
7 * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8 */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
14 #include <isl/ctx.h>
15 #include <isl_options_private.h>
16 #include <isl/ast_build.h>
17 #include <isl/schedule.h>
18 #include <isl/version.h>
20 struct isl_arg_choice isl_lp_solver_choice[] = {
21 {"tab", ISL_LP_TAB},
22 #ifdef ISL_PIPLIB
23 {"pip", ISL_LP_PIP},
24 #endif
25 {0}
28 struct isl_arg_choice isl_ilp_solver_choice[] = {
29 {"gbr", ISL_ILP_GBR},
30 #ifdef ISL_PIPLIB
31 {"pip", ISL_ILP_PIP},
32 #endif
33 {0}
36 struct isl_arg_choice isl_pip_solver_choice[] = {
37 {"tab", ISL_PIP_TAB},
38 #ifdef ISL_PIPLIB
39 {"pip", ISL_PIP_PIP},
40 #endif
41 {0}
44 struct isl_arg_choice isl_pip_context_choice[] = {
45 {"gbr", ISL_CONTEXT_GBR},
46 {"lexmin", ISL_CONTEXT_LEXMIN},
47 {0}
50 struct isl_arg_choice isl_gbr_choice[] = {
51 {"never", ISL_GBR_NEVER},
52 {"once", ISL_GBR_ONCE},
53 {"always", ISL_GBR_ALWAYS},
54 {0}
57 struct isl_arg_choice isl_closure_choice[] = {
58 {"isl", ISL_CLOSURE_ISL},
59 {"box", ISL_CLOSURE_BOX},
60 {0}
63 static struct isl_arg_choice bound[] = {
64 {"bernstein", ISL_BOUND_BERNSTEIN},
65 {"range", ISL_BOUND_RANGE},
66 {0}
69 static struct isl_arg_choice on_error[] = {
70 {"warn", ISL_ON_ERROR_WARN},
71 {"continue", ISL_ON_ERROR_CONTINUE},
72 {"abort", ISL_ON_ERROR_ABORT},
73 {0}
76 static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
77 {"isl", ISL_SCHEDULE_ALGORITHM_ISL},
78 {"feautrier", ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
79 {0}
82 static struct isl_arg_flags bernstein_recurse[] = {
83 {"none", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS, 0},
84 {"factors", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
85 ISL_BERNSTEIN_FACTORS},
86 {"intervals", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
87 ISL_BERNSTEIN_INTERVALS},
88 {"full", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
89 ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS},
90 {0}
93 static struct isl_arg_choice convex[] = {
94 {"wrap", ISL_CONVEX_HULL_WRAP},
95 {"fm", ISL_CONVEX_HULL_FM},
96 {0}
99 static struct isl_arg_choice fuse[] = {
100 {"max", ISL_SCHEDULE_FUSE_MAX},
101 {"min", ISL_SCHEDULE_FUSE_MIN},
105 static struct isl_arg_choice separation_bounds[] = {
106 {"explicit", ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT},
107 {"implicit", ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT},
111 static void print_version(void)
113 printf("%s", isl_version());
116 ISL_ARGS_START(struct isl_options, isl_options_args)
117 ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
118 isl_lp_solver_choice, ISL_LP_TAB, "lp solver to use")
119 ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
120 isl_ilp_solver_choice, ISL_ILP_GBR, "ilp solver to use")
121 ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
122 isl_pip_solver_choice, ISL_PIP_TAB, "pip solver to use")
123 ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
124 isl_pip_context_choice, ISL_CONTEXT_GBR,
125 "how to handle the pip context tableau")
126 ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
127 isl_gbr_choice, ISL_GBR_ALWAYS,
128 "how often to use generalized basis reduction")
129 ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
130 isl_closure_choice, ISL_CLOSURE_ISL,
131 "closure operation to use")
132 ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
133 "only perform basis reduction in first direction")
134 ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
135 ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
136 ISL_ARG_CHOICE(struct isl_options, on_error, 0, "on-error", on_error,
137 ISL_ON_ERROR_WARN, "how to react if an error is detected")
138 ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
139 "bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
140 ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
141 "bernstein-triangulate", 1,
142 "triangulate domains during Bernstein expansion")
143 ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
144 "detect simple symmetries in PIP input")
145 ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
146 convex, ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
147 ISL_ARG_BOOL(struct isl_options, coalesce_bounded_wrapping, 0,
148 "coalesce-bounded-wrapping", 1, "bound wrapping during coalescing")
149 ISL_ARG_INT(struct isl_options, schedule_max_coefficient, 0,
150 "schedule-max-coefficient", "limit", -1, "Only consider schedules "
151 "where the coefficients of the variable and parameter dimensions "
152 "do not exceed <limit>. A value of -1 allows arbitrary coefficients.")
153 ISL_ARG_INT(struct isl_options, schedule_max_constant_term, 0,
154 "schedule-max-constant-term", "limit", -1, "Only consider schedules "
155 "where the coefficients of the constant dimension do not exceed "
156 "<limit>. A value of -1 allows arbitrary coefficients.")
157 ISL_ARG_BOOL(struct isl_options, schedule_parametric, 0,
158 "schedule-parametric", 1, "construct possibly parametric schedules")
159 ISL_ARG_BOOL(struct isl_options, schedule_outer_zero_distance, 0,
160 "schedule-outer-zero-distance", 0,
161 "try to construct schedules with outer zero distances over "
162 "proximity dependences")
163 ISL_ARG_BOOL(struct isl_options, schedule_maximize_band_depth, 0,
164 "schedule-maximize-band-depth", 0,
165 "maximize the number of scheduling dimensions in a band")
166 ISL_ARG_BOOL(struct isl_options, schedule_split_scaled, 0,
167 "schedule-split-scaled", 1,
168 "split non-tilable bands with scaled schedules")
169 ISL_ARG_BOOL(struct isl_options, schedule_separate_components, 0,
170 "schedule-separate-components", 1,
171 "separate components in dependence graph")
172 ISL_ARG_CHOICE(struct isl_options, schedule_algorithm, 0,
173 "schedule-algorithm", isl_schedule_algorithm_choice,
174 ISL_SCHEDULE_ALGORITHM_ISL, "scheduling algorithm to use")
175 ISL_ARG_CHOICE(struct isl_options, schedule_fuse, 0, "schedule-fuse", fuse,
176 ISL_SCHEDULE_FUSE_MAX, "level of fusion during scheduling")
177 ISL_ARG_BOOL(struct isl_options, tile_scale_tile_loops, 0,
178 "tile-scale-tile-loops", 1, "scale tile loops")
179 ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
180 "ast-iterator-type", "type", "int",
181 "type used for iterators during printing of AST")
182 ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
183 "ast-build-atomic-upper-bound", 1, "generate atomic upper bounds")
184 ISL_ARG_BOOL(struct isl_options, ast_build_prefer_pdiv, 0,
185 "ast-build-prefer-pdiv", 1, "prefer pdiv operation over fdiv")
186 ISL_ARG_BOOL(struct isl_options, ast_build_exploit_nested_bounds, 0,
187 "ast-build-exploit-nested-bounds", 1,
188 "simplify conditions based on bounds of nested for loops")
189 ISL_ARG_BOOL(struct isl_options, ast_build_group_coscheduled, 0,
190 "ast-build-group-coscheduled", 0,
191 "keep coscheduled domain elements together")
192 ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0,
193 "ast-build-separation-bounds", separation_bounds,
194 ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT,
195 "bounds to use during separation")
196 ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0,
197 "ast-build-scale-strides", 1,
198 "allow iterators of strided loops to be scaled down")
199 ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0,
200 "ast-build-allow-else", 1, "generate if statements with else branches")
201 ISL_ARG_VERSION(print_version)
202 ISL_ARGS_END
204 ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
206 ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
208 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
209 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
211 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
212 on_error)
213 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
214 on_error)
216 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
217 coalesce_bounded_wrapping)
218 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
219 coalesce_bounded_wrapping)
221 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
222 gbr_only_first)
223 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
224 gbr_only_first)
226 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
227 schedule_max_coefficient)
228 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
229 schedule_max_coefficient)
231 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
232 schedule_max_constant_term)
233 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
234 schedule_max_constant_term)
236 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
237 schedule_maximize_band_depth)
238 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
239 schedule_maximize_band_depth)
241 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
242 schedule_split_scaled)
243 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
244 schedule_split_scaled)
246 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
247 schedule_separate_components)
248 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
249 schedule_separate_components)
251 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
252 schedule_outer_zero_distance)
253 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
254 schedule_outer_zero_distance)
256 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
257 schedule_algorithm)
258 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
259 schedule_algorithm)
261 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
262 schedule_fuse)
263 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
264 schedule_fuse)
266 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
267 tile_scale_tile_loops)
268 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
269 tile_scale_tile_loops)
271 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
272 ast_build_atomic_upper_bound)
273 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
274 ast_build_atomic_upper_bound)
276 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
277 ast_build_prefer_pdiv)
278 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
279 ast_build_prefer_pdiv)
281 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
282 ast_build_exploit_nested_bounds)
283 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
284 ast_build_exploit_nested_bounds)
286 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
287 ast_build_group_coscheduled)
288 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
289 ast_build_group_coscheduled)
291 ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
292 ast_iterator_type)
293 ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
294 ast_iterator_type)
296 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
297 ast_build_separation_bounds)
298 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
299 ast_build_separation_bounds)
301 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
302 ast_build_scale_strides)
303 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
304 ast_build_scale_strides)
306 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
307 ast_build_allow_else)
308 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
309 ast_build_allow_else)