Skip to content

Notes on compilation pipeline from Devito MLIR llvm IR .so

Anton Lydike edited this page Mar 14, 2023 · 5 revisions

Notes on compilation pipeline from Devito->MLIR -> llvm IR .so

Lowering Devito to XDSL

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

Optimizing with mlir-opt

cat raw.mlir | mlir-opt -cse -loop-invariant-code-motion --mlir-print-op-generic > optimized.mlir

Lowering MLIR to LLVM dialect

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

Lowering LLVM dialect to LLVMIR

cat llvm.mlir | mlir-translate --mlir-to-llvmir > llvm.ll

Lowering LLVM to .so

clang -shared llvm.ll -o kernel.so