Skip to content

Files

Failed to load latest commit information.

Latest commit

 Cannot retrieve latest commit at this time.

History

History

generic-mlir-dialect

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Setup

See docs for details. More useful is the tutorial slides.

Basically, first we'll first need to install LLVM. E.g. as a submodule at ../llvm-project. Then to set it up, we'll need to build.

cd llvm-project
mkdir build && cd build
cmake -G Ninja ../llvm \
  -DLLVM_ENABLE_PROJECTS=mlir \
  -DLLVM_BUILD_EXAMPLES=ON \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_ENABLE_RTTI=ON \
  -DLLVM_TARGETS_TO_BUILD="host"

cmake --build . --target check-mlir

Sometimes you might also want to change the targets in -DLLVM_TARGETS_TO_BUILD to include e.g. "NVPTX;AMDGPU".

Wherever you end up building LLVM, you'll need to change the appropriate variables in CMakeLists.txt, build.sh, and run.sh.

Notes

Setting up the first dialect is a huge pain. The documentation kinda sucks too, so this will be quite the learning experience.

Linking

  • Build LLVM/MLIR as described above, e.g. in $LLVM_BUILD_DIR.

  • Make sure to link them correctly to this project's cmake using both of $LLVM_DIR = $LLVM_BUILD_DIR/lib/cmake/llvm and $MLIR_DIR = $LLVM_BUILD_DIR/lib/cmake/mlir.

  • Include the relevant LLVM/MLIR packages, which will be determined by their configuration files from $LLVM_DIR, $MLIR_DIR.

  • Then add your own files

That is all of the necessary linking steps that I know of so far, but doesn't include e.g. testing.

The dialect itself

Now we can actually work with MLIR, and hopefully it's not as totally tedious.

TODOs

  • Play with dynamic dialects? docs