Skip to content
abadams edited this page Sep 12, 2014 · 19 revisions

Debugging inferred function bounds

HL_TRACE=1 prints out the boundaries of all realizations of Funcs. (Inlined Funcs don't really have boundaries.)

Higher values of HL_TRACE start to print the loads and stores too.

You can also call Func::trace_realizations to get a printf that displays the boundaries for a particular func.

Inspecting the value of an Expr at runtime

You can wrap a print around an Expr to print its value at runtime, e.g say you think b is taking on bad values in the following Func definition:

f(x) = a + b;

You could rewrite this to:

f(x) = a + print(b, " <- b has this value when x is ", x);

print returns the first argument, and prints all the arguments as a side-effect. The arguments may be of type Expr, std::string, const char *, int, or float.

You can also conditionally print:

f(x) = a + print_when(b < 0, b, " b was not supposed to be negative! It happened at x = ", x);

print_when returns the second argument. When the first argument is true, it prints all the arguments as a side-effect.