Replies: 19 comments 8 replies
-
There is an example app, which demonstrates how to use C backend. Basically, the generator has an option of emitting a C++ code, which you can then compile and link into your application. BTW, this might be of interest to you, we use a similar approach to generating a C++ code for one of the DSP in this branch |
Beta Was this translation helpful? Give feedback.
-
thanks . and if it's able to generate c++ code of xtensa DSP , is there a option to switch to generate c code for xtensa DSP . in our case , generating c code is preferred , looking forward to your reply . |
Beta Was this translation helpful? Give feedback.
-
@vksnk |
Beta Was this translation helpful? Give feedback.
-
Currently, there is no option to generate a plain C code for Xtensa DSP (and for C++ we require at least C++11, maybe even C++14; that being said Xtensa toolchain can handle that without any issues). For the xtensa-codegen branch, we currently support Q7 and Q8 DSPs. You'll need to add "xtensa" to your target string (by default for Q7; for Q8 add "xtensa_q8" on top of that), then generate C++ code using the standard approach. If you added xtensa-related features to your target string then generated code will be C++ with Xtensa DSP intrinsics, which you can compile and link to your application using toolchain from Cadence. |
Beta Was this translation helpful? Give feedback.
-
@vksnk cmake_minimum_required(VERSION 3.22) enable_testing() #Set up language settings #Find Halide #Generator(s) add_halide_library(pipeline_le15 FROM pipelinexxx.generator #Final executable(s) and then there's a cmake Warning : then i reviewed the generated code . this's no Xtensa DSP intrinsics . |
Beta Was this translation helpful? Give feedback.
-
@vksnk |
Beta Was this translation helpful? Give feedback.
-
Sorry, I don't use CMake that often, so might be incorrect, but I think the right way to do it is:
If you haven't seen it yet, there is a very good description for using CMake with Halide: https://github.com/halide/Halide/blob/main/README_cmake.md |
Beta Was this translation helpful? Give feedback.
-
Sorry, I thought I posted the answer, but apparently forgot to press comment button. |
Beta Was this translation helpful? Give feedback.
-
@vksnk cmake_minimum_required(VERSION 3.22) enable_testing() set(CMAKE_CXX_STANDARD 11) find_package(Halide REQUIRED) include_directories("/home/algo_share/projects/peiyuanluo/workspace/Halide/cmake-build-debug/apps/c_le1") add_halide_generator(pipelinexxx.generator SOURCES le15.cpp) #add_library(le15_dbg /home/algo_share/projects/peiyuanluo/workspace/Halide/cmake-build-debug/apps/c_le1/pipeline_le15.halide_generated.cpp) add_executable(le15 run.cpp) target_link_libraries(le15 any suggestions ? look forward to your reply . |
Beta Was this translation helpful? Give feedback.
-
i got it from https://github.com/halide/Halide/blob/main/README_cmake.md , halide support at least c++17 . |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, there is no way to limit generated code to c++11. It's possible that generated code is still compilable with c++11 though, but I think in general c++14 or later might be needed (unless I am confusing something, @steven-johnson might know the best). Are you getting errors when you try to compile? |
Beta Was this translation helpful? Give feedback.
-
Well, there's currently no way to do so. It's likely we could limit generated code to C++11 with some work, but I don't know how much work would be involved. I don't think anyone on the Halide team is likely to work on this anytime soon (if ever) but we'd consider PRs that do this. |
Beta Was this translation helpful? Give feedback.
-
@steven-johnson |
Beta Was this translation helpful? Give feedback.
-
@steven-johnson |
Beta Was this translation helpful? Give feedback.
-
now i am using Halide to generate xtensa feature code , then use xtensa tool chain to compile it . all code is based to c++ 17. then the tool chain shows me some error: it seems that i need more halide related source code to fix this error . and on the other hand , if i am generating pure C_BACKEND code , there's another library libpipeline_le15_native.a which i need to link it into my final executable . but as i am to generate a xtensa c++ code , i am using xtensa tool chain to compile the generated code , so may be i need the source code of libpipeline_le15_native.a ? |
Beta Was this translation helpful? Give feedback.
-
We're really not interested in supporting a pure C backend. It sounds like there is a code size issue that should be largely resolvable by careful choice of flags to the C++ compiler. C++ code that doesn't use various features and does not import unnecessary libraries should be very close to the same size as the same functionality in C. C++11 is likely worth preserving. |
Beta Was this translation helpful? Give feedback.
-
As mentioned before, we don't really have any plan in this update, nor are the current core contributors likely to add one anytime soon. If you (or any other contributors) wanted to focus on ways to improve the code size of the existing backend (e.g. by tweaking patterns that might improve codegen, or by figuring out the optimal set of compiler / linker flags to minimize tool-generated overhead), we'd very much welcome PRs in that area. |
Beta Was this translation helpful? Give feedback.
-
@steven-johnson @vksnk @zvookin #include "Halide.h" using namespace Halide; // Generators are a more structured way to do ahead-of-time
}; // We compile this file along with tools/GenGen.cpp. That file defines ie. now my generator code has only the vectorization feature , how to add the dma feature into that ? as you know , compuation in sram(xmem) is much faster . |
Beta Was this translation helpful? Give feedback.
-
@steven-johnson @vksnk @zvookin |
Beta Was this translation helpful? Give feedback.
-
as the tile has mentioned .
how to use halide generate c code ?
i want to re implement the method mentioned by https://www.es.ele.tue.nl/~rjordans/downloads/vocke2017taco.pdf which describe a way to integrate DSP backend into halide by c code generation .
any one has some idea ?
Beta Was this translation helpful? Give feedback.
All reactions