isl_options.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <isl/ctx.h>
  13. #include <isl_options_private.h>
  14. #include <isl/ast_build.h>
  15. #include <isl/schedule.h>
  16. #include <isl/version.h>
  17. struct isl_arg_choice isl_pip_context_choice[] = {
  18. {"gbr", ISL_CONTEXT_GBR},
  19. {"lexmin", ISL_CONTEXT_LEXMIN},
  20. {0}
  21. };
  22. struct isl_arg_choice isl_gbr_choice[] = {
  23. {"never", ISL_GBR_NEVER},
  24. {"once", ISL_GBR_ONCE},
  25. {"always", ISL_GBR_ALWAYS},
  26. {0}
  27. };
  28. struct isl_arg_choice isl_closure_choice[] = {
  29. {"isl", ISL_CLOSURE_ISL},
  30. {"box", ISL_CLOSURE_BOX},
  31. {0}
  32. };
  33. static struct isl_arg_choice bound[] = {
  34. {"bernstein", ISL_BOUND_BERNSTEIN},
  35. {"range", ISL_BOUND_RANGE},
  36. {0}
  37. };
  38. static struct isl_arg_choice on_error[] = {
  39. {"warn", ISL_ON_ERROR_WARN},
  40. {"continue", ISL_ON_ERROR_CONTINUE},
  41. {"abort", ISL_ON_ERROR_ABORT},
  42. {0}
  43. };
  44. static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
  45. {"isl", ISL_SCHEDULE_ALGORITHM_ISL},
  46. {"feautrier", ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
  47. {0}
  48. };
  49. static struct isl_arg_flags bernstein_recurse[] = {
  50. {"none", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS, 0},
  51. {"factors", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
  52. ISL_BERNSTEIN_FACTORS},
  53. {"intervals", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
  54. ISL_BERNSTEIN_INTERVALS},
  55. {"full", ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
  56. ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS},
  57. {0}
  58. };
  59. static struct isl_arg_choice convex[] = {
  60. {"wrap", ISL_CONVEX_HULL_WRAP},
  61. {"fm", ISL_CONVEX_HULL_FM},
  62. {0}
  63. };
  64. #define ISL_SCHEDULE_FUSE_MAX 0
  65. #define ISL_SCHEDULE_FUSE_MIN 1
  66. static struct isl_arg_choice fuse[] = {
  67. {"max", ISL_SCHEDULE_FUSE_MAX},
  68. {"min", ISL_SCHEDULE_FUSE_MIN},
  69. {0}
  70. };
  71. /* Callback for setting the "schedule-fuse" option.
  72. * This (now hidden) option tries to mimic an option that was
  73. * replaced by the schedule-serialize-sccs option.
  74. * Setting the old option to ISL_SCHEDULE_FUSE_MIN is now
  75. * expressed by turning on the schedule-serialize-sccs option.
  76. */
  77. static int set_fuse(void *opt, unsigned val)
  78. {
  79. struct isl_options *options = opt;
  80. options->schedule_serialize_sccs = (val == ISL_SCHEDULE_FUSE_MIN);
  81. return 0;
  82. }
  83. static struct isl_arg_choice separation_bounds[] = {
  84. {"explicit", ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT},
  85. {"implicit", ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT},
  86. {0}
  87. };
  88. static void print_version(void)
  89. {
  90. printf("%s", isl_version());
  91. }
  92. ISL_ARGS_START(struct isl_options, isl_options_args)
  93. ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
  94. isl_pip_context_choice, ISL_CONTEXT_GBR,
  95. "how to handle the pip context tableau")
  96. ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
  97. isl_gbr_choice, ISL_GBR_ALWAYS,
  98. "how often to use generalized basis reduction")
  99. ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
  100. isl_closure_choice, ISL_CLOSURE_ISL,
  101. "closure operation to use")
  102. ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
  103. "only perform basis reduction in first direction")
  104. ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
  105. ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
  106. ISL_ARG_CHOICE(struct isl_options, on_error, 0, "on-error", on_error,
  107. ISL_ON_ERROR_WARN, "how to react if an error is detected")
  108. ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
  109. "bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
  110. ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
  111. "bernstein-triangulate", 1,
  112. "triangulate domains during Bernstein expansion")
  113. ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
  114. "detect simple symmetries in PIP input")
  115. ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
  116. convex, ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
  117. ISL_ARG_BOOL(struct isl_options, coalesce_bounded_wrapping, 0,
  118. "coalesce-bounded-wrapping", 1, "bound wrapping during coalescing")
  119. ISL_ARG_BOOL(struct isl_options, coalesce_preserve_locals, 0,
  120. "coalesce-preserve-locals", 0,
  121. "preserve local variables during coalescing")
  122. ISL_ARG_INT(struct isl_options, schedule_max_coefficient, 0,
  123. "schedule-max-coefficient", "limit", -1, "Only consider schedules "
  124. "where the coefficients of the variable and parameter dimensions "
  125. "do not exceed <limit>. A value of -1 allows arbitrary coefficients.")
  126. ISL_ARG_INT(struct isl_options, schedule_max_constant_term, 0,
  127. "schedule-max-constant-term", "limit", -1, "Only consider schedules "
  128. "where the coefficients of the constant dimension do not exceed "
  129. "<limit>. A value of -1 allows arbitrary coefficients.")
  130. ISL_ARG_BOOL(struct isl_options, schedule_parametric, 0,
  131. "schedule-parametric", 1, "construct possibly parametric schedules")
  132. ISL_ARG_BOOL(struct isl_options, schedule_outer_coincidence, 0,
  133. "schedule-outer-coincidence", 0,
  134. "try to construct schedules where the outer member of each band "
  135. "satisfies the coincidence constraints")
  136. ISL_ARG_BOOL(struct isl_options, schedule_maximize_band_depth, 0,
  137. "schedule-maximize-band-depth", 0,
  138. "maximize the number of scheduling dimensions in a band")
  139. ISL_ARG_BOOL(struct isl_options, schedule_maximize_coincidence, 0,
  140. "schedule-maximize-coincidence", 0,
  141. "maximize the number of coincident dimensions in a band")
  142. ISL_ARG_BOOL(struct isl_options, schedule_split_scaled, 0,
  143. "schedule-split-scaled", 1,
  144. "split non-tilable bands with scaled schedules")
  145. ISL_ARG_BOOL(struct isl_options, schedule_treat_coalescing, 0,
  146. "schedule-treat-coalescing", 1,
  147. "try and prevent or adjust schedules that perform loop coalescing")
  148. ISL_ARG_BOOL(struct isl_options, schedule_separate_components, 0,
  149. "schedule-separate-components", 1,
  150. "separate components in dependence graph")
  151. ISL_ARG_BOOL(struct isl_options, schedule_whole_component, 0,
  152. "schedule-whole-component", 0,
  153. "try and compute schedule for entire component first")
  154. ISL_ARG_CHOICE(struct isl_options, schedule_algorithm, 0,
  155. "schedule-algorithm", isl_schedule_algorithm_choice,
  156. ISL_SCHEDULE_ALGORITHM_ISL, "scheduling algorithm to use")
  157. ISL_ARG_BOOL(struct isl_options, schedule_carry_self_first, 0,
  158. "schedule-carry-self-first", 1, "try and carry self-dependences first")
  159. ISL_ARG_BOOL(struct isl_options, schedule_serialize_sccs, 0,
  160. "schedule-serialize-sccs", 0,
  161. "serialize strongly connected components in dependence graph")
  162. ISL_ARG_PHANTOM_USER_CHOICE_F(0, "schedule-fuse", fuse, &set_fuse,
  163. ISL_SCHEDULE_FUSE_MAX, "level of fusion during scheduling",
  164. ISL_ARG_HIDDEN)
  165. ISL_ARG_BOOL(struct isl_options, tile_scale_tile_loops, 0,
  166. "tile-scale-tile-loops", 1, "scale tile loops")
  167. ISL_ARG_BOOL(struct isl_options, tile_shift_point_loops, 0,
  168. "tile-shift-point-loops", 1, "shift point loops to start at zero")
  169. ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
  170. "ast-iterator-type", "type", "int",
  171. "type used for iterators during printing of AST")
  172. ISL_ARG_BOOL(struct isl_options, ast_always_print_block, 0,
  173. "ast-always-print-block", 0, "print for and if bodies as a block "
  174. "regardless of the number of statements in the body")
  175. ISL_ARG_BOOL(struct isl_options, ast_print_outermost_block, 0,
  176. "ast-print-outermost-block", 1, "print outermost block node as a block")
  177. ISL_ARG_BOOL(struct isl_options, ast_print_macro_once, 0,
  178. "ast-print-macro-once", 0, "only print macro definitions once")
  179. ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
  180. "ast-build-atomic-upper-bound", 1, "generate atomic upper bounds")
  181. ISL_ARG_BOOL(struct isl_options, ast_build_prefer_pdiv, 0,
  182. "ast-build-prefer-pdiv", 1, "prefer pdiv operation over fdiv")
  183. ISL_ARG_BOOL(struct isl_options, ast_build_detect_min_max, 0,
  184. "ast-build-detect-min-max", 0, "detect min/max expressions")
  185. ISL_ARG_BOOL(struct isl_options, ast_build_exploit_nested_bounds, 0,
  186. "ast-build-exploit-nested-bounds", 1,
  187. "simplify conditions based on bounds of nested for loops")
  188. ISL_ARG_BOOL(struct isl_options, ast_build_group_coscheduled, 0,
  189. "ast-build-group-coscheduled", 0,
  190. "keep coscheduled domain elements together")
  191. ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0,
  192. "ast-build-separation-bounds", separation_bounds,
  193. ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT,
  194. "bounds to use during separation")
  195. ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0,
  196. "ast-build-scale-strides", 1,
  197. "allow iterators of strided loops to be scaled down")
  198. ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0,
  199. "ast-build-allow-else", 1, "generate if statements with else branches")
  200. ISL_ARG_BOOL(struct isl_options, ast_build_allow_or, 0,
  201. "ast-build-allow-or", 1, "generate if conditions with disjunctions")
  202. ISL_ARG_BOOL(struct isl_options, print_stats, 0, "print-stats", 0,
  203. "print statistics for every isl_ctx")
  204. ISL_ARG_ULONG(struct isl_options, max_operations, 0,
  205. "max-operations", 0, "default number of maximal operations per isl_ctx")
  206. ISL_ARG_VERSION(print_version)
  207. ISL_ARGS_END
  208. ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
  209. ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
  210. ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
  211. ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
  212. ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  213. on_error)
  214. ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  215. on_error)
  216. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  217. pip_symmetry)
  218. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  219. pip_symmetry)
  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. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  225. coalesce_preserve_locals)
  226. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  227. coalesce_preserve_locals)
  228. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  229. gbr_only_first)
  230. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  231. gbr_only_first)
  232. ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
  233. schedule_max_coefficient)
  234. ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
  235. schedule_max_coefficient)
  236. ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
  237. schedule_max_constant_term)
  238. ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
  239. schedule_max_constant_term)
  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. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  245. schedule_maximize_coincidence)
  246. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  247. schedule_maximize_coincidence)
  248. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  249. schedule_split_scaled)
  250. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  251. schedule_split_scaled)
  252. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  253. schedule_treat_coalescing)
  254. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  255. schedule_treat_coalescing)
  256. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  257. schedule_separate_components)
  258. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  259. schedule_separate_components)
  260. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  261. schedule_whole_component)
  262. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  263. schedule_whole_component)
  264. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  265. schedule_outer_coincidence)
  266. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  267. schedule_outer_coincidence)
  268. ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  269. schedule_algorithm)
  270. ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  271. schedule_algorithm)
  272. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  273. schedule_carry_self_first)
  274. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  275. schedule_carry_self_first)
  276. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  277. schedule_serialize_sccs)
  278. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  279. schedule_serialize_sccs)
  280. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  281. tile_scale_tile_loops)
  282. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  283. tile_scale_tile_loops)
  284. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  285. tile_shift_point_loops)
  286. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  287. tile_shift_point_loops)
  288. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  289. ast_build_atomic_upper_bound)
  290. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  291. ast_build_atomic_upper_bound)
  292. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  293. ast_build_prefer_pdiv)
  294. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  295. ast_build_prefer_pdiv)
  296. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  297. ast_build_detect_min_max)
  298. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  299. ast_build_detect_min_max)
  300. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  301. ast_build_exploit_nested_bounds)
  302. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  303. ast_build_exploit_nested_bounds)
  304. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  305. ast_build_group_coscheduled)
  306. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  307. ast_build_group_coscheduled)
  308. ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
  309. ast_iterator_type)
  310. ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
  311. ast_iterator_type)
  312. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  313. ast_always_print_block)
  314. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  315. ast_always_print_block)
  316. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  317. ast_print_outermost_block)
  318. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  319. ast_print_outermost_block)
  320. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  321. ast_print_macro_once)
  322. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  323. ast_print_macro_once)
  324. ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  325. ast_build_separation_bounds)
  326. ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
  327. ast_build_separation_bounds)
  328. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  329. ast_build_scale_strides)
  330. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  331. ast_build_scale_strides)
  332. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  333. ast_build_allow_else)
  334. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  335. ast_build_allow_else)
  336. ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  337. ast_build_allow_or)
  338. ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
  339. ast_build_allow_or)