Skip to content

Commit feb6685

Browse files
committed
[OpOptimization] Sync with buddy-compiler/buddy-mlir#201
1 parent 4e3e288 commit feb6685

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,34 @@ $ ninja <your target operation benchmark>
235235
// - conv2d-nchw-fchw-benchmark
236236
// - matmul-benchmark
237237
```
238-
OpenMP is required in matmul-benchmark, make sure `libomp` and `libomp-dev` (on Ubuntu and Debian) / `libomp-devel` (on Redhat and SUSE) have been installed.
238+
### matmul-benchmark
239+
`OpenMP` and `lld` LTO is required in matmul-benchmark. To ensure version compatibility with the project, it's recommended to use the LLVM toolchains built within the `buddy-benchmark`. Follow the steps below:
240+
- build llvm toolchains with `lld` and `OpenMP`.
241+
```
242+
$ cd buddy-mlir/llvm/build
243+
$ cmake -G Ninja ../llvm \
244+
-DLLVM_ENABLE_PROJECTS="mlir;clang;lld;openmp" \
245+
-DLLVM_TARGETS_TO_BUILD="host;RISCV" \
246+
-DLLVM_ENABLE_ASSERTIONS=ON \
247+
-DLLVM_ENABLE_RUNTIMES=all \
248+
-DOPENMP_ENABLE_LIBOMPTARGET=OFF \
249+
-DCMAKE_BUILD_TYPE=RELEASE
250+
```
251+
- use the `clang++` in `buddy-mlir/llvm/build/bin`.
252+
```
253+
$ mkdir build && cd build
254+
$ cmake -G Ninja .. \
255+
-DCMAKE_BUILD_TYPE=RELEASE \
256+
-DOP_OPTIMIZATION_BENCHMARKS=ON \
257+
-DCMAKE_CXX_COMPILER=/PATH/TO/BUDDY-MLIR/BUILD/bin/clang++ \
258+
-DBUDDY_MLIR_BUILD_DIR=/PATH/TO/BUDDY-MLIR/BUILD/
259+
$ ninja matmul-benchmark
260+
```
261+
- `matmul-benchmark` need to load the `libomp.so` in `buddy-mlir/llvm/build/lib` to execute, here's a temporary way without root.
262+
263+
```
264+
$ export LD_LIBRARY_PATH=/PATH/TO/BUDDY-MLIR/BUILD/lib/:$LD_LIBRARY_PATH
265+
```
239266

240267
Run TVM operation optimization benchmark cases.
241268
- Install TVM ([steps](./thirdparty/README.md#tvm)).

benchmarks/OpOptimization/MatMul/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function(build_batch_matmul_broadcast step)
123123
COMMAND cat ${BUDDY_SOURCE_DIR}/benchmarks/OpOptimization/MatMul/BatchMatMul.mlir |
124124
sed 's/bm_batch_matmul/batch_matmul_broadcast_${step}/g' |
125125
${BUDDY_MLIR_BUILD_DIR}/bin/buddy-opt
126-
-batchmatmul-optimize="step-placeholder=${step}"
126+
-batchmatmul-optimize="vector-size=${step}"
127127
-expand-strided-metadata
128128
-affine-super-vectorize
129129
-lower-affine
@@ -178,7 +178,7 @@ add_executable(matmul-benchmark
178178
MatMulBenchmark.cpp
179179
)
180180

181-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fopenmp -flto")
181+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -fopenmp -flto -fuse-ld=lld")
182182

183183
target_link_libraries(matmul-benchmark
184184
GoogleBenchmark

0 commit comments

Comments
 (0)