buddy-compiler / buddy-benchmark

Benchmark Framework for Buddy Projects
Apache License 2.0
44 stars 34 forks source link

illegal hardware instruction (core dumped) #34

Closed linuxlonelyeagle closed 2 years ago

linuxlonelyeagle commented 2 years ago

Describe the bug

when i input ./image-processing-benchmark ../../benchmarks/ImageProcessing/Images/YuTu.png laplacianKernelAlign in the shell. I encountered this situation that illegal hardware instruction (core dumped)

To Reproduce

Steps to reproduce the behavior.
cd buddy-benchmark
cd build  
cd bin
./image-processing-benchmark ../../benchmarks/ImageProcessing/Images/YuTu.png laplacianKernelAlign
Running ./image-processing-benchmark
Run on (16 X 2900 MHz CPU s)
CPU Caches:
L1 Data 32 KiB (x8)
L1 Instruction 32 KiB (x8)
L2 Unified 512 KiB (x8)
L3 Unified 4096 KiB (x2)
Load Average: 1.13, 0.91, 0.74
WARNING  CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
WARNING  Library was built as DEBUG. Timings may be affected.
-------------------------------------------------------------
Benchmark                   Time             CPU   Iterations
-------------------------------------------------------------
OpenCV_Filter2D/1     3471609 ns      3460337 ns          201
Eigen_Convolve2D/1   76930880 ns     76863287 ns            9
MLIR_Conv2D/1        12705419 ns     12695988 ns           55
[1]    4396 illegal hardware instruction (core dumped)  ./image-processing-benchmark ../../benchmarks/ImageProcessing/Images/YuTu.png

Desktop :

zhanghb97 commented 2 years ago

From your description, the issue is from the DIP Corr2D case.

Please try to run the DIP Corr2D example (“Lowering DIP Dialect” section in the buddy-mlir README) and see if you can reproduce the issue again.

Note: your device seems not support AVX512, please use right configuration (avx2) for the ISA vector extension.

zhanghb97 commented 2 years ago

Ping @meshtag for this DIP related issue.

meshtag commented 2 years ago

@linuxlonelyeagle .mlir files relevant to IP benchmark use buddy-opt to lower appropriate IP related MLIR Ops for generating the required .o file. As mentioned by @zhanghb97 , please ensure that you are able to build the DIP example by following instructions mentioned in this readme file.

linuxlonelyeagle commented 2 years ago

I have solved the problem, here is what i do.When i need use the cmake command.I make the CMake Options what is -DBUDDY_OPT_ATTR equal to avx2,because my computer don‘t support avx512f. For example,when i build the Image Processing Benchmark,my input is below:

$ cd buddy-benchmark
$ mkdir build && cd build
$ cmake -G Ninja .. \
    -DIMAGE_PROCESSING_BENCHMARKS=ON \
    -DOpenCV_DIR=/PATH/TO/OPENCV/BUILD/ \
    -DEIGEN_DIR=/PATH/TO/EIGEN/SOURCE/CODE \
    -DBUDDY_OPT_BUILD_DIR=/PATH/TO/BUDDY-MLIR/BUILD/
    -DBUDDY_OPT_ATTR=avx2     
$ ninja image-processing-benchmark

So we should point out -DBUDDY_OPT_ATTR=avx2

meshtag commented 2 years ago

Glad you solved the issue! I think the buddy-mlir doc mentions it clearly that ISA vector extension should be specified by the user as per their machine. Quoting the following line from budd-mlir's readme file :

You should specify the strip mining size (e.g. 256) and ISA vector extension (e.g. avx512f).

Feel free to create a PR if you think we should mention this more clearly in either buddy-mlir or buddy-benchmark's readme file(s).

PS : Please close the issue if you think your concerns are addressed.