Skip to content

Commit 0495dfd

Browse files
Add command line option --disable-polly
When this option is passed `@polly` declarations will be ignored. This facilitates debugging or evaluating performance differences between using/not using Polly without having to manually remove `@polly` declarations from functions.
1 parent 03e7c79 commit 0495dfd

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

base/options.jl

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ immutable JLOptions
2424
check_bounds::Int8
2525
depwarn::Int8
2626
can_inline::Int8
27+
polly::Int8
2728
fast_math::Int8
2829
worker::Ptr{UInt8}
2930
handle_signals::Int8

src/codegen.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4111,7 +4111,7 @@ static std::unique_ptr<Module> emit_function(jl_lambda_info_t *lam, jl_llvm_func
41114111
#endif
41124112

41134113
#ifdef USE_POLLY
4114-
if (!jl_has_meta(code, polly_sym)) {
4114+
if (!jl_has_meta(code, polly_sym) || jl_options.polly == JL_OPTIONS_POLLY_OFF) {
41154115
f->addFnAttr(polly::PollySkipFnAttr);
41164116
}
41174117
#endif

src/init.c

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jl_options_t jl_options = { 0, // quiet
7878
JL_OPTIONS_CHECK_BOUNDS_DEFAULT, // check_bounds
7979
1, // depwarn
8080
1, // can_inline
81+
JL_OPTIONS_POLLY_ON, // polly
8182
JL_OPTIONS_FAST_MATH_DEFAULT,
8283
0, // worker
8384
JL_OPTIONS_HANDLE_SIGNALS_ON,

src/jloptions.c

+12
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static const char opts[] =
4646
" -O, --optimize={0,1,2,3} Set the optimization level (default 2 if unspecified or 3 if specified as -O)\n"
4747
" --inline={yes|no} Control whether inlining is permitted (overrides functions declared as @inline)\n"
4848
" --check-bounds={yes|no} Emit bounds checks always or never (ignoring declarations)\n"
49+
" --polly={yes|no} Enable or disable the polyhedral optimizer Polly (overrides @polly declaration)\n"
4950
" --math-mode={ieee,fast} Disallow or enable unsafe floating point optimizations (overrides @fastmath declaration)\n\n"
5051

5152
// error and warning options
@@ -83,6 +84,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
8384
opt_output_bc,
8485
opt_depwarn,
8586
opt_inline,
87+
opt_polly,
8688
opt_math_mode,
8789
opt_worker,
8890
opt_bind_to,
@@ -125,6 +127,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
125127
{ "output-incremental",required_argument, 0, opt_incremental },
126128
{ "depwarn", required_argument, 0, opt_depwarn },
127129
{ "inline", required_argument, 0, opt_inline },
130+
{ "polly", required_argument, 0, opt_polly },
128131
{ "math-mode", required_argument, 0, opt_math_mode },
129132
{ "handle-signals", required_argument, 0, opt_handle_signals },
130133
// hidden command line options
@@ -398,6 +401,15 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
398401
jl_errorf("julia: invalid argument to --inline (%s)", optarg);
399402
}
400403
break;
404+
case opt_polly:
405+
if (!strcmp(optarg,"yes"))
406+
jl_options.polly = JL_OPTIONS_POLLY_ON;
407+
else if (!strcmp(optarg,"no"))
408+
jl_options.polly = JL_OPTIONS_POLLY_OFF;
409+
else {
410+
jl_errorf("julia: invalid argument to --polly (%s)", optarg);
411+
}
412+
break;
401413
case opt_math_mode:
402414
if (!strcmp(optarg,"ieee"))
403415
jl_options.fast_math = JL_OPTIONS_FAST_MATH_OFF;

src/julia.h

+4
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,7 @@ typedef struct {
16681668
int8_t check_bounds;
16691669
int8_t depwarn;
16701670
int8_t can_inline;
1671+
int8_t polly;
16711672
int8_t fast_math;
16721673
const char *worker;
16731674
int8_t handle_signals;
@@ -1722,6 +1723,9 @@ JL_DLLEXPORT int jl_generating_output(void);
17221723
#define JL_OPTIONS_DEPWARN_ON 1
17231724
#define JL_OPTIONS_DEPWARN_ERROR 2
17241725

1726+
#define JL_OPTIONS_POLLY_ON 1
1727+
#define JL_OPTIONS_POLLY_OFF 0
1728+
17251729
#define JL_OPTIONS_FAST_MATH_ON 1
17261730
#define JL_OPTIONS_FAST_MATH_OFF 2
17271731
#define JL_OPTIONS_FAST_MATH_DEFAULT 0

test/cmdlineargs.jl

+7
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ let exename = `$(Base.julia_cmd()) --precompiled=yes --startup-file=no`
186186
# --inline takes yes/no as argument
187187
@test !success(`$exename --inline=false`)
188188

189+
# --polly
190+
@test readchomp(`$exename -E "Bool(Base.JLOptions().polly)"`) == "true"
191+
@test readchomp(`$exename --polly=yes -E "Bool(Base.JLOptions().polly)"`) == "true"
192+
@test readchomp(`$exename --polly=no -E "Bool(Base.JLOptions().polly)"`) == "false"
193+
# --polly takes yes/no as argument
194+
@test !success(`$exename --polly=false`)
195+
189196
# --fast-math
190197
let JL_OPTIONS_FAST_MATH_DEFAULT = 0,
191198
JL_OPTIONS_FAST_MATH_ON = 1,

0 commit comments

Comments
 (0)