When I try to print() an expression within a generator, I cannot build:
Internal Error at /home/halidenightly/build_bot/worker/linux-64-gcc53-800/halide/src/CodeGen_OpenCL_Dev.cpp:229 triggered by user code at :
Condition failed: !function_takes_user_context(op->name):
Aborted (core dumped)
I don't understand this error message, what is it?
EDIT 1: I've now included fuller code below.
#include "Halide.h"
using namespace Halide;
class SimpleGenerator : public Generator<SimpleGenerator>{
public:
Input<Buffer<uint8_t >> source{"src", 2};
Input<Buffer<uint8_t >> reference{"ref", 2};
Output<Buffer<uint8_t >> output{"out", 2};
void generate(){
intermediate(x, y) = print(source(x, y), "source at (", x,", ", y, ")") + print(reference(x, y));
output(x, y) = intermediate(x, y);
}
void schedule(){
Var xo("xo"), yo("yo"), xi("xi"), yi("yi");
if (get_target().has_gpu_feature()) {
std::cout << "Using GPU schedule\n";
output.gpu_tile(x, y, xo, yo, xi, yi, 16, 16, TailStrategy::GuardWithIf);
} else {
std::cout << "Using CPU schedule\n";
}
}
private:
Func intermediate{"intermediate"};
Var x{"x"}, y{"y"};
};
HALIDE_REGISTER_GENERATOR(SimpleGenerator, simple_generator)
EDIT 2: I narrowed down the issue; this issue occurs when try to target the GPU with OpenCL. I remember reading somewhere that printing Halide Exprs on the GPU is buggy. Does anyone know how to solve this?