add packaging
[platform/upstream/isl.git] / isl_options.c
1 /*
2  * Copyright 2008-2009 Katholieke Universiteit Leuven
3  *
4  * Use of this software is governed by the MIT license
5  *
6  * Written by Sven Verdoolaege, K.U.Leuven, Departement
7  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8  */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
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>
19
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}
26 };
27
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}
34 };
35
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}
42 };
43
44 struct isl_arg_choice isl_pip_context_choice[] = {
45         {"gbr",         ISL_CONTEXT_GBR},
46         {"lexmin",      ISL_CONTEXT_LEXMIN},
47         {0}
48 };
49
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}
55 };
56
57 struct isl_arg_choice isl_closure_choice[] = {
58         {"isl",         ISL_CLOSURE_ISL},
59         {"box",         ISL_CLOSURE_BOX},
60         {0}
61 };
62
63 static struct isl_arg_choice bound[] = {
64         {"bernstein",   ISL_BOUND_BERNSTEIN},
65         {"range",       ISL_BOUND_RANGE},
66         {0}
67 };
68
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}
74 };
75
76 static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
77         {"isl",         ISL_SCHEDULE_ALGORITHM_ISL},
78         {"feautrier",   ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
79         {0}
80 };
81
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}
91 };
92
93 static struct isl_arg_choice convex[] = {
94         {"wrap",        ISL_CONVEX_HULL_WRAP},
95         {"fm",          ISL_CONVEX_HULL_FM},
96         {0}
97 };
98
99 static struct isl_arg_choice fuse[] = {
100         {"max",         ISL_SCHEDULE_FUSE_MAX},
101         {"min",         ISL_SCHEDULE_FUSE_MIN},
102         {0}
103 };
104
105 static struct isl_arg_choice separation_bounds[] = {
106         {"explicit",    ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT},
107         {"implicit",    ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT},
108         {0}
109 };
110
111 static void print_version(void)
112 {
113         printf("%s", isl_version());
114 }
115
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_BOOL(struct isl_options, tile_shift_point_loops, 0,
180         "tile-shift-point-loops", 1, "shift point loops to start at zero")
181 ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
182         "ast-iterator-type", "type", "int",
183         "type used for iterators during printing of AST")
184 ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
185         "ast-build-atomic-upper-bound", 1, "generate atomic upper bounds")
186 ISL_ARG_BOOL(struct isl_options, ast_build_prefer_pdiv, 0,
187         "ast-build-prefer-pdiv", 1, "prefer pdiv operation over fdiv")
188 ISL_ARG_BOOL(struct isl_options, ast_build_exploit_nested_bounds, 0,
189         "ast-build-exploit-nested-bounds", 1,
190         "simplify conditions based on bounds of nested for loops")
191 ISL_ARG_BOOL(struct isl_options, ast_build_group_coscheduled, 0,
192         "ast-build-group-coscheduled", 0,
193         "keep coscheduled domain elements together")
194 ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0,
195         "ast-build-separation-bounds", separation_bounds,
196         ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT,
197         "bounds to use during separation")
198 ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0,
199         "ast-build-scale-strides", 1,
200         "allow iterators of strided loops to be scaled down")
201 ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0,
202         "ast-build-allow-else", 1, "generate if statements with else branches")
203 ISL_ARG_BOOL(struct isl_options, ast_build_allow_or, 0,
204         "ast-build-allow-or", 1, "generate if conditions with disjunctions")
205 ISL_ARG_VERSION(print_version)
206 ISL_ARGS_END
207
208 ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
209
210 ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
211
212 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
213 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
214
215 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
216         on_error)
217 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
218         on_error)
219
220 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
221         coalesce_bounded_wrapping)
222 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
223         coalesce_bounded_wrapping)
224
225 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
226         gbr_only_first)
227 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
228         gbr_only_first)
229
230 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
231         schedule_max_coefficient)
232 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
233         schedule_max_coefficient)
234
235 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
236         schedule_max_constant_term)
237 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
238         schedule_max_constant_term)
239
240 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
241         schedule_maximize_band_depth)
242 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
243         schedule_maximize_band_depth)
244
245 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
246         schedule_split_scaled)
247 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
248         schedule_split_scaled)
249
250 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
251         schedule_separate_components)
252 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
253         schedule_separate_components)
254
255 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
256         schedule_outer_zero_distance)
257 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
258         schedule_outer_zero_distance)
259
260 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
261         schedule_algorithm)
262 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
263         schedule_algorithm)
264
265 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
266         schedule_fuse)
267 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
268         schedule_fuse)
269
270 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
271         tile_scale_tile_loops)
272 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
273         tile_scale_tile_loops)
274
275 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
276         tile_shift_point_loops)
277 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
278         tile_shift_point_loops)
279
280 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
281         ast_build_atomic_upper_bound)
282 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
283         ast_build_atomic_upper_bound)
284
285 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
286         ast_build_prefer_pdiv)
287 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
288         ast_build_prefer_pdiv)
289
290 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
291         ast_build_exploit_nested_bounds)
292 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
293         ast_build_exploit_nested_bounds)
294
295 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
296         ast_build_group_coscheduled)
297 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
298         ast_build_group_coscheduled)
299
300 ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
301         ast_iterator_type)
302 ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
303         ast_iterator_type)
304
305 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
306         ast_build_separation_bounds)
307 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
308         ast_build_separation_bounds)
309
310 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
311         ast_build_scale_strides)
312 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
313         ast_build_scale_strides)
314
315 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
316         ast_build_allow_else)
317 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
318         ast_build_allow_else)
319
320 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
321         ast_build_allow_or)
322 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
323         ast_build_allow_or)