Skip to content

Latest commit

 

History

History
56 lines (39 loc) · 2.23 KB

README_OLD.md

File metadata and controls

56 lines (39 loc) · 2.23 KB

Hands-on-MLIR

A simple project to optimize linalg.matmul using mlir framework. Currently developing in progress. Feel free to create an issue if you have any suggestions or problems.

What can it do?

Currently, this project can lower the linalg.matmul to affine dialect with tiling. Also, this project provide a simple benchmark to measure the optimization's gFlops. However, it is not fast right now.(at about 2 gFlops compared to ~100 gFlops of mkl performance)

To-do

  • explicit affine data packing mechanism. (affineDataCopyGenerate simply cannot work when the tensor shape is unknown. Maybe I should implement it myself.)
  • vector ld/st & compute.
  • And more...

Install

Install MLIR

Install it in your preferable way. This project should be compatible with the main branch of mlir.

Install this project

If you didn't enable address sanitizer when installing the mlir, please remove the following lines in CMakeLists.txt. (I'm to lazy to make it configurable)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")

Then use the following command to compile.

$ cd Hands-on-MLIR
$ mkdir build && cd build
$ cmake -G Ninja .. \
    -DMLIR_DIR=/your/path/to/llvm-project/build/lib/cmake/mlir \
    -DLLVM_DIR=/your/path/to/llvm-project/build/lib/cmake/llvm \
    -DLLVM_ENABLE_ASSERTIONS=ON

or you can use this setup in VSCode.

 "cmake.configureArgs": [
     "-DMLIR_DIR=/your/path/to/llvm-project/build/lib/cmake/mlir",
     "-DLLVM_DIR=/your/path/to/llvm-project/build/lib/cmake/llvm",
     "-DLLVM_ENABLE_ASSERTIONS=ON"
 ],

Reference