Skip to content

[OpOptimization] Add BatchMatMul benchmark and [OpOptimization] Further optimize BatchMatMulBroadcast and add OpenMP tests#73

Open
EllisLambda wants to merge 3 commits into
buddy-compiler:mainfrom
EllisLambda:main
Open

[OpOptimization] Add BatchMatMul benchmark and [OpOptimization] Further optimize BatchMatMulBroadcast and add OpenMP tests#73
EllisLambda wants to merge 3 commits into
buddy-compiler:mainfrom
EllisLambda:main

Conversation

@EllisLambda

@EllisLambda EllisLambda commented Aug 19, 2023

Copy link
Copy Markdown

The explanation of the further optimize:

EllisLambda@d8888a4#r126890428

Comment thread benchmarks/OpOptimization/MatMul/BatchMatMulBroadcast.mlir Outdated
Comment thread benchmarks/OpOptimization/MatMul/BatchMatMulBroadcast.mlir Outdated
Comment thread benchmarks/OpOptimization/MatMul/MatMulBenchmark.cpp Outdated
@xlinsist

Copy link
Copy Markdown
Collaborator

Note: The file "BatchMatMulBroadcast.mlir" can be generated from "BatchMatMul.mlir" using --batchmatmul-optimize pass developed in buddy-compiler/buddy-mlir#187.

@xlinsist

Copy link
Copy Markdown
Collaborator

This PR can be merged once these issues mentioned above are fixed. @EllisLambda

Comment thread benchmarks/OpOptimization/MatMul/MatMulBenchmark.cpp Outdated
Comment thread benchmarks/OpOptimization/MatMul/MatMulBenchmark.cpp Outdated
@xlinsist

xlinsist commented Sep 9, 2023

Copy link
Copy Markdown
Collaborator

@EllisLambda Please also make changes based on the suggestions mentioned above.

@EllisLambda

Copy link
Copy Markdown
Author

@EllisLambda Please also make changes based on the suggestions mentioned above.

@xlinsist Problems have been fixed.

@EllisLambda

Copy link
Copy Markdown
Author

@xlinsist New commit have been pushed.

@EllisLambda EllisLambda changed the title [OpOptimization] Add BatchMatMul benchmark. [OpOptimization] Add BatchMatMul benchmark and [OpOptimization] Further optimize BatchMatMulBroadcast and add OpenMP tests Sep 9, 2023
@EllisLambda EllisLambda force-pushed the main branch 2 times, most recently from 100bb85 to fc5e694 Compare September 11, 2023 06:08
Comment thread README.md
@EllisLambda EllisLambda force-pushed the main branch 5 times, most recently from aa4bf23 to feb6685 Compare September 19, 2023 16:06
@xlinsist

Copy link
Copy Markdown
Collaborator

It seems that we have to carefully support lld and openmp. I will test this PR tomorrow.

Comment thread README.md
$ cmake -G Ninja .. \
-DCMAKE_BUILD_TYPE=RELEASE \
-DOP_OPTIMIZATION_BENCHMARKS=ON \
-DCMAKE_CXX_COMPILER=clang++ \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we only need to use clang++ in matmul-benchmark, so the modification here should be withdrawn.

Comment thread README.md
-DLLVM_ENABLE_RUNTIMES=all \
-DOPENMP_ENABLE_LIBOMPTARGET=OFF \
-DCMAKE_BUILD_TYPE=RELEASE
```

@xlinsist xlinsist Sep 20, 2023

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a specific construction process is required(in matmul-benchmark), please ensure that the construction process you provide is complete. For example, add the step $ ninja, since in the default construction process we only use $ ninja check-clang check-mlir.

Comment thread README.md
$ cmake -G Ninja .. \
-DCMAKE_BUILD_TYPE=RELEASE \
-DOP_OPTIMIZATION_BENCHMARKS=ON \
-DCMAKE_CXX_COMPILER=/PATH/TO/BUDDY-MLIR/BUILD/bin/clang++ \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/PATH/TO/BUDDY-MLIR/BUILD/bin/clang++ ->
/PATH/TO/BUDDY-MLIR/llvm/build/bin/clang++

Comment thread README.md
-DBUDDY_MLIR_BUILD_DIR=/PATH/TO/BUDDY-MLIR/BUILD/
$ ninja matmul-benchmark
```
- `matmul-benchmark` need to load the `libomp.so` in `buddy-mlir/llvm/build/lib` to execute, here's a temporary way without root.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommand to rephrase the description here like this:

To execute matmul-benchmark in buddy-benchmark/build/bin, The libomp.so file from buddy-mlir/llvm/build/lib need to be loaded. Here is a temporary workaround without root access:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
I have successfully constructed matmul-benchmark and verified the optimization, but there are some warnings using clang++ with argument -no-pie and -fuse-ld=lld. Are you able to reproduce them in your machine and can we eliminate them?

Comment thread benchmarks/OpOptimization/MatMul/MatMulBenchmark.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants