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.
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)
- 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 it in your preferable way. This project should be compatible with the main branch of mlir.
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"
],
- MLIR:抄了很多(
- buddy-mlir:同样抄了很多(
- polymage-labs/mlirx:版本太老了,很多都没法抄(
- Polyhedral Model 三篇:知道多面体优化的基本概念。