1

I'd like to set an environment variable when running my code, e.g. DEBUG=TRUE ./run_my_halide_program, and only see the output of Halide's print_when() statements when said variable is set. However, print_when() seems to only take Halide::Expr's, not booleans. How can I do this in Halide?

1 Answers1

1

I got it. You can construct Halide::Expr from an int value. The constructed Expr can then be used with print_when().

So something along the lines of this:

char* do_i_debug = getenv("DEBUG");
int debug_val = do_i_debug == nullptr ? 0 : 1; // we'll use 1 to mean debug

Halide::Expr DEBUG_HALIDE = Expr(debug_val) == 1;
Halide::print_when(DEBUG_HALIDE, expr_or_func_to_print);