File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -125,8 +125,15 @@ string Module::compile() {
125125 }
126126 else {
127127 cc = util::getFromEnv (target.compiler_env , target.compiler );
128- cflags = util::getFromEnv (" TACO_CFLAGS" ,
129- " -O3 -ffast-math -std=c99" ) + " -shared -fPIC" ;
128+ #ifdef TACO_DEBUG
129+ // In debug mode, compile the generated code with debug symbols and a
130+ // low optimization level.
131+ string defaultFlags = " -g -O0 -std=c99" ;
132+ #else
133+ // Otherwise, use the standard set of optimizing flags.
134+ string defaultFlags = " -O3 -ffast-math -std=c99" ;
135+ #endif
136+ cflags = util::getFromEnv (" TACO_CFLAGS" , defaultFlags) + " -shared -fPIC" ;
130137#if USE_OPENMP
131138 cflags += " -fopenmp" ;
132139#endif
Original file line number Diff line number Diff line change @@ -34,7 +34,13 @@ TEST(qcd, mul1) {
3434 tau = z (i) * z (j) * theta (i,j) * theta (i,j);
3535
3636 tau.evaluate ();
37+ // Using -O0 to compile the generated kernel yields a slightly different
38+ // answer than using -O3.
39+ #ifdef TACO_DEBUG
40+ ASSERT_DOUBLE_EQ (0.41212798763234648 , getScalarValue (tau));
41+ #else
3742 ASSERT_DOUBLE_EQ (0.41212798763234737 , getScalarValue (tau));
43+ #endif
3844}
3945
4046TEST (qcd, mul2) {
You can’t perform that action at this time.
0 commit comments