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