1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//! Defines the constant key names for various Weld properties.
//!
//! This module is re-exported at the top-level.

/// Bytes a single `WeldContext` is allowed to allocate.
///
/// If a run allocates more memory than specified by this parameter across *all runs using the
/// context*, the run will fail with an `OutOfMemoryError`.
///
/// This parameter should be set in a configuration passed to a `WeldContext`.
pub const CONF_MEMORY_LIMIT_KEY: &str = "weld.memory.limit";

/// Specifies the number of threads to use during execution.
///
/// This parameter should be set in a configuration passed to a `WeldContext`.
pub const CONF_THREADS_KEY: &str = "weld.threads";

/// Specifies whether tracing should be enabled when compiling the program.
///
/// Tracing will print, during runtime, the internal Weld instruction before executing it. This has
/// a very large performance overhead and will print lots of output on large inputs: it should only
/// be enabled for debugging (e.g., to identify a crash).
///
/// This parameter should be set for compilation.
pub const CONF_TRACE_RUN_KEY: &str = "weld.compile.traceExecution";

/// Specifies an ordered list of the optimizations to apply to a Weld program.
///
/// This supercedes the default optimization set.
///
/// This parameter should be set for compilation.
pub const CONF_OPTIMIZATION_PASSES_KEY: &str = "weld.optimization.passes";

/// Enables experimental (unstable) optimizations.
///
/// Experimental optimizations may produce adverse effects in certain programs, as they are
/// unstable/still being tested. They may also improve the performance of a program, however.
///
/// This parameter should be set for compilation.
pub const CONF_EXPERIMENTAL_PASSES_KEY: &str = "weld.optimization.applyExperimentalTransforms";

/// Enables internal Sequential IR (SIR) optimizations.
///
/// This enables optimizations over the internal "sequential" Weld IR. Certain optimizations are
/// easier to apply over this IR, and are thus implemented over the SIR rather than the expression
/// tree.
///
/// This parameter should be set for compilation.
pub const CONF_SIR_OPT_KEY: &str = "weld.optimization.sirOptimization";

/// Set the LLVM optimization level.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_OPTIMIZATION_LEVEL_KEY: &str = "weld.llvm.optimization.level";

/// Toggles LLVM loop unrolling.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_UNROLLER_KEY: &str = "weld.llvm.optimization.unroller";

/// Toggles LLVM vectorization.
///
/// Requires targetPasses to be true to have an effect.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_VECTORIZER_KEY: &str = "weld.llvm.optimization.vectorizer";

/// Toggles LLVM target passes.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_TARGET_PASSES_KEY: &str = "weld.llvm.optimization.targetPasses";

/// Toggles full module optimizations.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_MODULE_OPTS_KEY: &str = "weld.llvm.optimization.moduleOpts";

/// Toggles per-function optimizations.
///
/// This parameter should be set for compilation.
pub const CONF_LLVM_FUNC_OPTS_KEY: &str = "weld.llvm.optimization.funcOpts";

/// Sets the symbol name of the entry-point function.
pub const CONF_LLVM_RUN_FUNC_NAME_KEY: &str = "weld.llvm.runFunctionName";

/// Enables dumping code during compilation.
///
/// This will produce several files in the directory specified by `weld.compile.dumpCodeDir`:
///
/// * The un-optimized Weld program passed to the compiler
/// * THe optimized Weld program.
/// * The internal SIR representation of the optimized program.
/// * Unoptimized backend code (e.g., LLVM) generated by the Weld backend.
/// * Optimized backend code (e.g.,) after LLVM passes.
/// * Assembly code for target architecture (e.g,. x64 assembly)
///
/// This parameter should be set for compilation.
pub const CONF_DUMP_CODE_KEY: &str = "weld.compile.dumpCode";

/// Specifies the directory to dump code into.
///
/// This parameter should be set for compilation.
pub const CONF_DUMP_CODE_DIR_KEY: &str = "weld.compile.dumpCodeDir";

/// Specifies the filename prefix for dumped code.
///
/// This parameter should be set for compilation.
pub const CONF_DUMP_CODE_FILENAME_KEY: &str = "weld.compile.dumpCodeFilename";

/// Specifies the formats to dump for dumped code.
///
/// This key does not have an explicit default value: if it is not specified, all formats
/// are dumped. The possible formats are:
///
/// weld,weldopt,llvm,llvmopt,sir,assembly.
///
/// This parameter should be set for compilation.
pub const CONF_DUMP_CODE_FORMATS_KEY: &str = "weld.compile.dumpCodeFormats";

/// Enables runtime bounds checking for loops before executing them.
///
/// This parameter should be set for compilation.
pub const CONF_ENABLE_BOUNDS_CHECKS_KEY: &str = "weld.compile.enableBoundsChecks";

/// Default memory limit.
pub const CONF_MEMORY_LIMIT_DEFAULT: i64 = 1_000_000_000;

/// Default number of threads.
pub const CONF_THREADS_DEFAULT: i32 = 1;

/// Default setting for SIR optimization.
pub const CONF_SIR_OPT_DEFAULT: bool = true;

/// Default LLVM optimization level.
pub const CONF_LLVM_OPTIMIZATION_LEVEL_DEFAULT: u32 = 2;

/// Default LLVM loop unroller setting.
pub const CONF_LLVM_UNROLLER_DEFAULT: bool = true;

/// Default LLVM loop vectorizer setting.
pub const CONF_LLVM_VECTORIZER_DEFAULT: bool = true;

/// Default LLVM target analysis passes.
pub const CONF_LLVM_TARGET_PASSES_DEFAULT: bool = true;

/// Default LLVM module passes setting.
pub const CONF_LLVM_MODULE_OPTS_DEFAULT: bool = true;

/// Default LLVM function passes setting.
pub const CONF_LLVM_FUNC_OPTS_DEFAULT: bool = true;

/// Default symbol name for LLVM entry-point function.
pub const CONF_LLVM_RUN_FUNC_NAME_DEFAULT: &str = "run";

/// Default setting for whether to dump code.
pub const CONF_DUMP_CODE_DEFAULT: bool = false;

/// Default setting for whether to trace SIR instructions.
pub const CONF_TRACE_RUN_DEFAULT: bool = false;

/// Default setting for whether to enable experimental (unstable) optimizations.
pub const CONF_EXPERIMENTAL_PASSES_DEFAULT: bool = false;

/// Default setting for whether to enable bounds checking.
pub const CONF_ENABLE_BOUNDS_CHECKS_DEFAULT: bool = false;

/// Default directory for dumping code.
pub const CONF_DUMP_CODE_DIR_DEFAULT: &str = ".";

/// Default set of optimization passes.
pub const CONF_OPTIMIZATION_PASSES_DEFAULT: &[&str] = &[
    "inline-zip",
    "inline-let",
    "inline-apply",
    "loop-fusion",
    "unroll-static-loop",
    "infer-size",
    "algebraic",
    "inline-literals",
    "cse",
    "short-circuit-booleans",
    "predicate",
    "vectorize",
];