Skip to content

Instantly share code, notes, and snippets.

@dkurt
Last active August 8, 2017 11:20
Show Gist options
  • Save dkurt/44b69ad6b82b2b7cbd0a080d14afa399 to your computer and use it in GitHub Desktop.
Save dkurt/44b69ad6b82b2b7cbd0a080d14afa399 to your computer and use it in GitHub Desktop.
sample
{
Halide::Var x("x"), xo("xo"), xi("xi");
Halide::Func f("f");
f(x) = x + 777;
f.bound(x, 0, 16);
f.split(x, xo, xi, 8).gpu_threads(xi).gpu_blocks(xo);
f.output_buffer().dim(0).set_bounds(0, 16);
Halide::Target target = Halide::get_host_target();
target.set_feature(Halide::Target::OpenCL);
// target.set_feature(Halide::Target::UserContext);
target.set_feature(Halide::Target::NoBoundsQuery);
target.set_feature(Halide::Target::NoAsserts);
// target.set_feature(Halide::Target::NoRuntime);
// f.compile_jit(target);
Halide::Module m = f.compile_to_module({}, "myfunc", target).resolve_submodules();
Halide::Internal::LoweredFunc lf = m.get_function_by_name("myfunc");
Halide::Internal::CodeGen_OpenCL_Dev codegen(target);
codegen.init_module();
Halide::Internal::DeviceArgument devArg("_f_buffer", true, Halide::Int(32), 1, 16);
codegen.add_kernel(lf.body, m.functions()[0].name, {devArg});
std::vector<char> src = codegen.compile_to_src();
std::cout << std::string(src.begin(), src.end()) << '\n';
CV_Assert(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment