ppcg_options.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright 2010-2011 INRIA Saclay
  3. *
  4. * Use of this software is governed by the MIT license
  5. *
  6. * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
  7. * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
  8. * 91893 Orsay, France
  9. */
  10. #include "ppcg_options.h"
  11. static struct isl_arg_choice target[] = {
  12. {"c", PPCG_TARGET_C},
  13. {"cuda", PPCG_TARGET_CUDA},
  14. {"opencl", PPCG_TARGET_OPENCL},
  15. {0}
  16. };
  17. /* Set defaults that depend on the target.
  18. * In particular, set --schedule-outer-coincidence iff target is a GPU.
  19. */
  20. void ppcg_options_set_target_defaults(struct ppcg_options *options)
  21. {
  22. char *argv[2] = { NULL };
  23. argv[0] = "ppcg_options_set_target_defaults";
  24. if (options->target == PPCG_TARGET_C)
  25. argv[1] = "--no-schedule-outer-coincidence";
  26. else
  27. argv[1] = "--schedule-outer-coincidence";
  28. isl_options_parse(options->isl, 2, argv, ISL_ARG_ALL);
  29. }
  30. /* Callback that is called whenever the "target" option is set (to "val").
  31. * The callback is called after target has been updated.
  32. *
  33. * Call ppcg_options_set_target_defaults to reset the target-dependent options.
  34. */
  35. static int set_target(void *opt, unsigned val)
  36. {
  37. struct ppcg_options *options = opt;
  38. ppcg_options_set_target_defaults(options);
  39. return 0;
  40. }
  41. ISL_ARGS_START(struct ppcg_debug_options, ppcg_debug_options_args)
  42. ISL_ARG_BOOL(struct ppcg_debug_options, dump_schedule_constraints, 0,
  43. "dump-schedule-constraints", 0, "dump schedule constraints")
  44. ISL_ARG_BOOL(struct ppcg_debug_options, dump_schedule, 0,
  45. "dump-schedule", 0, "dump isl computed schedule")
  46. ISL_ARG_BOOL(struct ppcg_debug_options, dump_final_schedule, 0,
  47. "dump-final-schedule", 0, "dump PPCG computed schedule")
  48. ISL_ARG_BOOL(struct ppcg_debug_options, dump_sizes, 0,
  49. "dump-sizes", 0,
  50. "dump effectively used per kernel tile, grid and block sizes")
  51. ISL_ARG_BOOL(struct ppcg_debug_options, verbose, 'v', "verbose", 0, NULL)
  52. ISL_ARGS_END
  53. ISL_ARGS_START(struct ppcg_options, ppcg_opencl_options_args)
  54. ISL_ARG_STR(struct ppcg_options, opencl_compiler_options, 0, "compiler-options",
  55. "options", NULL, "options to pass to the OpenCL compiler")
  56. ISL_ARG_BOOL(struct ppcg_options, opencl_use_gpu, 0, "use-gpu", 1,
  57. "use GPU device (if available)")
  58. ISL_ARG_STR_LIST(struct ppcg_options, opencl_n_include_file,
  59. opencl_include_files, 0, "include-file", "filename",
  60. "file to #include in generated OpenCL code")
  61. ISL_ARG_BOOL(struct ppcg_options, opencl_print_kernel_types, 0,
  62. "print-kernel-types", 1,
  63. "print definitions of types in the kernel file")
  64. ISL_ARG_BOOL(struct ppcg_options, opencl_embed_kernel_code, 0,
  65. "embed-kernel-code", 0, "embed kernel code into host code")
  66. ISL_ARGS_END
  67. ISL_ARGS_START(struct ppcg_options, ppcg_options_args)
  68. ISL_ARG_CHILD(struct ppcg_options, isl, "isl", &isl_options_args, "isl options")
  69. ISL_ARG_CHILD(struct ppcg_options, debug, NULL, &ppcg_debug_options_args,
  70. "debugging options")
  71. ISL_ARG_BOOL(struct ppcg_options, group_chains, 0, "group-chains", 1,
  72. "group chains of interdependent statements that are executed "
  73. "consecutively in the original schedule before scheduling")
  74. ISL_ARG_BOOL(struct ppcg_options, reschedule, 0, "reschedule", 1,
  75. "replace original schedule by isl computed schedule")
  76. ISL_ARG_BOOL(struct ppcg_options, scale_tile_loops, 0,
  77. "scale-tile-loops", 1, NULL)
  78. ISL_ARG_BOOL(struct ppcg_options, wrap, 0, "wrap", 1, NULL)
  79. ISL_ARG_BOOL(struct ppcg_options, use_shared_memory, 0, "shared-memory", 1,
  80. "use shared memory in kernel code")
  81. ISL_ARG_BOOL(struct ppcg_options, use_private_memory, 0, "private-memory", 1,
  82. "use private memory in kernel code")
  83. ISL_ARG_STR(struct ppcg_options, ctx, 0, "ctx", "context", NULL,
  84. "Constraints on parameters")
  85. ISL_ARG_BOOL(struct ppcg_options, non_negative_parameters, 0,
  86. "assume-non-negative-parameters", 0,
  87. "assume all parameters are non-negative)")
  88. ISL_ARG_BOOL(struct ppcg_options, tile, 0, "tile", 0,
  89. "perform tiling (C target)")
  90. ISL_ARG_INT(struct ppcg_options, tile_size, 'S', "tile-size", "size", 32, NULL)
  91. ISL_ARG_BOOL(struct ppcg_options, isolate_full_tiles, 0, "isolate-full-tiles",
  92. 0, "isolate full tiles from partial tiles (hybrid tiling)")
  93. ISL_ARG_STR(struct ppcg_options, sizes, 0, "sizes", "sizes", NULL,
  94. "Per kernel tile, grid and block sizes")
  95. ISL_ARG_INT(struct ppcg_options, max_shared_memory, 0,
  96. "max-shared-memory", "size", 8192, "maximal amount of shared memory")
  97. ISL_ARG_BOOL(struct ppcg_options, openmp, 0, "openmp", 0,
  98. "Generate OpenMP macros (only for C target)")
  99. ISL_ARG_USER_OPT_CHOICE(struct ppcg_options, target, 0, "target", target,
  100. &set_target, PPCG_TARGET_CUDA, PPCG_TARGET_CUDA,
  101. "the target to generate code for")
  102. ISL_ARG_BOOL(struct ppcg_options, linearize_device_arrays, 0,
  103. "linearize-device-arrays", 1,
  104. "linearize all device arrays, even those of fixed size")
  105. ISL_ARG_BOOL(struct ppcg_options, allow_gnu_extensions, 0,
  106. "allow-gnu-extensions", 1,
  107. "allow the use of GNU extensions in generated code")
  108. ISL_ARG_BOOL(struct ppcg_options, live_range_reordering, 0,
  109. "live-range-reordering", 1,
  110. "allow successive live ranges on the same memory element "
  111. "to be reordered")
  112. ISL_ARG_BOOL(struct ppcg_options, hybrid, 0, "hybrid", 0,
  113. "apply hybrid tiling whenever a suitable input pattern is found "
  114. "(GPU targets)")
  115. ISL_ARG_BOOL(struct ppcg_options, unroll_copy_shared, 0, "unroll-copy-shared",
  116. 0, "unroll code for copying to/from shared memory")
  117. ISL_ARG_BOOL(struct ppcg_options, unroll_gpu_tile, 0, "unroll-gpu-tile", 0,
  118. "unroll code inside tile on GPU targets")
  119. ISL_ARG_GROUP("opencl", &ppcg_opencl_options_args, "OpenCL options")
  120. ISL_ARG_STR(struct ppcg_options, save_schedule_file, 0, "save-schedule",
  121. "file", NULL, "save isl computed schedule to <file>")
  122. ISL_ARG_STR(struct ppcg_options, load_schedule_file, 0, "load-schedule",
  123. "file", NULL, "load schedule from <file>, "
  124. "using it instead of an isl computed schedule")
  125. ISL_ARGS_END