-
Notifications
You must be signed in to change notification settings - Fork 72
Notes on compilation pipeline from Devito MLIR llvm IR .so
George Bisbas edited this page Jun 3, 2023
·
5 revisions
The current example.py
can be found on our branch; it applies the iet_to_standard_mlir
pass
python3 example.py > raw.mlir
This lowers devito to something that's mlir-compatible
cat raw.mlir | mlir-opt -cse -loop-invariant-code-motion --mlir-print-op-generic > optimized.mlir
cat optimized.mlir | mlir-opt -convert-scf-to-cf -convert-cf-to-llvm -convert-arith-to-llvm -convert-math-to-llvm -convert-func-to-llvm -reconcile-unrealized-casts > llvm.mlir
cat llvm.mlir | mlir-translate --mlir-to-llvmir > llvm.ll
clang -O3 -shared llvm.ll -o kernel.so
Building instructions from Anton:
# mlir
RUN mkdir llvm-project \
&& cd llvm-project \
&& git init \
&& git remote add origin https://github.com/llvm/llvm-project.git \
&& git fetch origin 04fc02e583b06b846315904a55af9c273c8b20b9 \
&& git reset --hard FETCH_HEAD
RUN mkdir llvm-project/build \
&& cd llvm-project/build \
&& cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="mlir;clang;openmp" -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DLLVM_ENABLE_LLD=ON
RUN cd llvm-project/build \
&& cmake --build . --target install