ffb5b86c0d7c5c0eac75c93418ecd792b22d6d59
[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 GNU LGPLv2.1 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/version.h>
17
18 struct isl_arg_choice isl_lp_solver_choice[] = {
19         {"tab",         ISL_LP_TAB},
20 #ifdef ISL_PIPLIB
21         {"pip",         ISL_LP_PIP},
22 #endif
23         {0}
24 };
25
26 struct isl_arg_choice isl_ilp_solver_choice[] = {
27         {"gbr",         ISL_ILP_GBR},
28 #ifdef ISL_PIPLIB
29         {"pip",         ISL_ILP_PIP},
30 #endif
31         {0}
32 };
33
34 struct isl_arg_choice isl_pip_solver_choice[] = {
35         {"tab",         ISL_PIP_TAB},
36 #ifdef ISL_PIPLIB
37         {"pip",         ISL_PIP_PIP},
38 #endif
39         {0}
40 };
41
42 struct isl_arg_choice isl_pip_context_choice[] = {
43         {"gbr",         ISL_CONTEXT_GBR},
44         {"lexmin",      ISL_CONTEXT_LEXMIN},
45         {0}
46 };
47
48 struct isl_arg_choice isl_gbr_choice[] = {
49         {"never",       ISL_GBR_NEVER},
50         {"once",        ISL_GBR_ONCE},
51         {"always",      ISL_GBR_ALWAYS},
52         {0}
53 };
54
55 struct isl_arg_choice isl_closure_choice[] = {
56         {"isl",         ISL_CLOSURE_ISL},
57         {"box",         ISL_CLOSURE_BOX},
58         {0}
59 };
60
61 static struct isl_arg_choice bound[] = {
62         {"bernstein",   ISL_BOUND_BERNSTEIN},
63         {"range",       ISL_BOUND_RANGE},
64         {0}
65 };
66
67 static struct isl_arg_choice on_error[] = {
68         {"warn",        ISL_ON_ERROR_WARN},
69         {"continue",    ISL_ON_ERROR_CONTINUE},
70         {"abort",       ISL_ON_ERROR_ABORT},
71         {0}
72 };
73
74 static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
75         {"isl",         ISL_SCHEDULE_ALGORITHM_ISL},
76         {"feautrier",   ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
77         {0}
78 };
79
80 static struct isl_arg_flags bernstein_recurse[] = {
81         {"none",        ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS, 0},
82         {"factors",     ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
83                         ISL_BERNSTEIN_FACTORS},
84         {"intervals",   ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
85                         ISL_BERNSTEIN_INTERVALS},
86         {"full",        ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
87                         ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS},
88         {0}
89 };
90
91 static struct isl_arg_choice convex[] = {
92         {"wrap",        ISL_CONVEX_HULL_WRAP},
93         {"fm",          ISL_CONVEX_HULL_FM},
94         {0}
95 };
96
97 static void print_version(void)
98 {
99         printf("%s", isl_version());
100 }
101
102 ISL_ARGS_START(struct isl_options, isl_options_args)
103 ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
104         isl_lp_solver_choice,   ISL_LP_TAB, "lp solver to use")
105 ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
106         isl_ilp_solver_choice,  ISL_ILP_GBR, "ilp solver to use")
107 ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
108         isl_pip_solver_choice,  ISL_PIP_TAB, "pip solver to use")
109 ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
110         isl_pip_context_choice, ISL_CONTEXT_GBR,
111         "how to handle the pip context tableau")
112 ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
113         isl_gbr_choice, ISL_GBR_ONCE,
114         "how often to use generalized basis reduction")
115 ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
116         isl_closure_choice,     ISL_CLOSURE_ISL,
117         "closure operation to use")
118 ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
119         "only perform basis reduction in first direction")
120 ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
121         ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
122 ISL_ARG_CHOICE(struct isl_options, on_error, 0, "on-error", on_error,
123         ISL_ON_ERROR_WARN, "how to react if an error is detected")
124 ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
125         "bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
126 ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
127         "bernstein-triangulate", 1,
128         "triangulate domains during Bernstein expansion")
129 ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
130         "detect simple symmetries in PIP input")
131 ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
132         convex, ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
133 ISL_ARG_INT(struct isl_options, schedule_max_constant_term, 0,
134         "schedule-max-constant-term", "limit", -1, "Only consider schedules "
135         "where the coefficients of the constant dimension do not exceed "
136         "<limit>. A value of -1 allows arbitrary coefficients.")
137 ISL_ARG_BOOL(struct isl_options, schedule_parametric, 0,
138         "schedule-parametric", 1, "construct possibly parametric schedules")
139 ISL_ARG_BOOL(struct isl_options, schedule_outer_zero_distance, 0,
140         "schedule-outer-zero-distance", 0,
141         "try to construct schedules with outer zero distances over "
142         "proximity dependences")
143 ISL_ARG_BOOL(struct isl_options, schedule_maximize_band_depth, 0,
144         "schedule-maximize-band-depth", 0,
145         "maximize the number of scheduling dimensions in a band")
146 ISL_ARG_BOOL(struct isl_options, schedule_split_parallel, 0,
147         "schedule-split-parallel", 1,
148         "split non-tilable bands with parallel schedules")
149 ISL_ARG_CHOICE(struct isl_options, schedule_algorithm, 0,
150         "schedule-algorithm", isl_schedule_algorithm_choice,
151         ISL_SCHEDULE_ALGORITHM_ISL, "scheduling algorithm to use")
152 ISL_ARG_VERSION(print_version)
153 ISL_ARGS_END
154
155 ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
156
157 ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
158
159 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
160 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
161
162 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
163         on_error)
164 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
165         on_error)
166
167 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
168         gbr_only_first)
169 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
170         gbr_only_first)
171
172 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
173         schedule_max_constant_term)
174 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
175         schedule_max_constant_term)
176
177 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
178         schedule_maximize_band_depth)
179 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
180         schedule_maximize_band_depth)
181
182 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
183         schedule_split_parallel)
184 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
185         schedule_split_parallel)
186
187 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
188         schedule_outer_zero_distance)
189 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
190         schedule_outer_zero_distance)
191
192 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
193         schedule_algorithm)
194 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
195         schedule_algorithm)