1.下载安装llvm
git clone --depth 1 --branch llvmorg-13.0.0 https://github.com/llvm/llvm-project.git
mkdir llvm-install
mkdir llvm-build
cd llvm-build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../llvm-install\
-DLLVM_ENABLE_PROJECTS="clang;lld;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD="X86;ARM;NVPTX;AArch64;Mips;Hexagon;WebAssembly" \
-DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_RTTI=ON -DLLVM_BUILD_32_BITS=OFF \
../llvm-project/llvm
make -j4
make install
或者直接下载编译好的llvm: https://github.com/llvm/llvm-project/releases/tag/llvmorg-13.0.0
2.下载编译halide
git clone https://github.com/halide/Halide.git
export LLVM_CONFIG=$PWD/llvm-install/bin/llvm-config
export CLANG = $PWD/llvm-install/bin/clang
cd ..
mkdir halide_build
cd halide_build
make -f ../Halide/Makefile
3.demo演示
g++ halide01.cpp -I halide_build/include -L halide_build/bin -lHalide -lpthread -ldl -o halide_01 -std=c++17
export LD_LIBRARY_PATH=halide_build/bin/
./halide_01
|