Halide generator to produce c++ file... #8852
-
|
Hallo, I'm trying to integrate Halide generator to my cmake project and have issues with debug configurations... And final step - I link But there is problem with debug build configuration. Actually i expected Halide generated c++ source file instead of obj / libs. So i can then include this c++ file to the project and can easily step into functions with the debugger in usual way. But unfortunately i didn't find the way how to produce c++ sources instead of object files. Any help please ? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
Halide does have a C++ backend; however, you probably don't want to use it. Our standard CPU backends go through LLVM directly, which typically leads to better performance than we could get by generating C++ code. Basically the reason is that we have specialized information about Halide programs (e.g., bounds, pointer aliasing, vector instructions, etc.) that is simpler to communicate in the IR directly. The C++ backend mostly exists to support scenarios where LLVM lacks support. That said, It can be accessed via the
This is untrue. Different platforms have different SIMD models. What works well on x86 does not necessarily work well on ARM or vice-versa.
We are always open to hearing proposals to improve the debugging experience. As far as I am aware, the VS debugger will allow you to step through the compiled assembly. |
Beta Was this translation helpful? Give feedback.
-
Can I ask how you acquired or built Halide? If via pip, I should specify that it is release-mode only (providing debug binaries is a TODO). To get you unstuck for now, you can set If you don't want to set that globally, you could add this after the call to set_property(TARGET resize.generator PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDLL) |
Beta Was this translation helpful? Give feedback.
-
|
Traditional stepping debuggers aren't that useful to debug Halide pipelines. I'm not sure what you're trying to do exactly, but here are some general debugging Halide tips: If you're debugging bad output, I usually compute_root everything and then use Func::debug_to_file or print_when wrapped around individual Exprs to inspect individual values to see why I'm not getting the output I expect. There are also the trace_* methods on Func, but those tend to produce a lot of output. If you're debugging a segfault it's almost always due to a malformed input or output halide_buffer_t. Try adding -debug to the target to see the fields of the halide_buffer_ts that are being passed. Maybe there's a bad stride or host pointer. You can combine this with a tracing method or target flag to see what the pipeline was doing when it crashed. You can also get segfaults if you turn on no_asserts and then pass a too-small input. Definitely don't use no_asserts while debugging anything and only turn it on if there's a measurable performance benefit (it very rarely helps performance - it's mostly for saving code size). If you want to understand the structure of the computation that your schedule implies and how that corresponds to the assembly generated, compile to conceptual_stmt_html and open it in a browser. If you're debugging a performance issue, use the -profile target flag to see where all the time is going, and then go inspect that stage in the conceptual_stmt_html output to see what might be making it slow. If the inner loop looks great, maybe it's running more than you expect. Func::trace_realizations can help diagnose this. |
Beta Was this translation helpful? Give feedback.
Halide does have a C++ backend; however, you probably don't want to use it. Our standard CPU backends go through LLVM directly, which typically leads to better performance than we could get by generating C++ code. Basically the reason is that we have specialized information about Halide programs (e.g., bounds, pointer aliasing, vector instructions, etc.) that is simpler to communicate in the IR directly. T…