add support for generating ASTs from schedule relations
[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_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_VERSION(print_version)
200 ISL_ARGS_END
201
202 ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
203
204 ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
205
206 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
207 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
208
209 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
210         on_error)
211 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
212         on_error)
213
214 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
215         coalesce_bounded_wrapping)
216 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
217         coalesce_bounded_wrapping)
218
219 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
220         gbr_only_first)
221 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
222         gbr_only_first)
223
224 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
225         schedule_max_coefficient)
226 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
227         schedule_max_coefficient)
228
229 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
230         schedule_max_constant_term)
231 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
232         schedule_max_constant_term)
233
234 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
235         schedule_maximize_band_depth)
236 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
237         schedule_maximize_band_depth)
238
239 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
240         schedule_split_scaled)
241 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
242         schedule_split_scaled)
243
244 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
245         schedule_separate_components)
246 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
247         schedule_separate_components)
248
249 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
250         schedule_outer_zero_distance)
251 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
252         schedule_outer_zero_distance)
253
254 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
255         schedule_algorithm)
256 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
257         schedule_algorithm)
258
259 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
260         schedule_fuse)
261 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
262         schedule_fuse)
263
264 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
265         tile_scale_tile_loops)
266 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
267         tile_scale_tile_loops)
268
269 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
270         ast_build_atomic_upper_bound)
271 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
272         ast_build_atomic_upper_bound)
273
274 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
275         ast_build_prefer_pdiv)
276 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
277         ast_build_prefer_pdiv)
278
279 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
280         ast_build_exploit_nested_bounds)
281 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
282         ast_build_exploit_nested_bounds)
283
284 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
285         ast_build_group_coscheduled)
286 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
287         ast_build_group_coscheduled)
288
289 ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
290         ast_iterator_type)
291 ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
292         ast_iterator_type)
293
294 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
295         ast_build_separation_bounds)
296 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
297         ast_build_separation_bounds)
298
299 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
300         ast_build_scale_strides)
301 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
302         ast_build_scale_strides)