I installed intel MKL. So I want to compare intel MKL to Mac Accelerate Framework. Mac Accelerate is optimized to Mac. It’s interesting which is faster.
I compared them using cblas_dgemm function.
Source code for Mac Accelerate
Compile the following command.
c++ -framework Accelerate -o dgemm_accel dgemm_accel.cpp
Source code for Intel MKL
Compile the following command.
c++ -DMKL_ILP64 -m64 -I${MKLROOT}/include ${MKLROOT}/lib/libmkl_intel_ilp64.a ${MKLROOT}/lib/libmkl_intel_thread.a ${MKLROOT}/lib/libmkl_core.a -liomp5 -lpthread -lm -ldl -o dgemm_mkl dgemm_mkl.cpp
Results
Run both commands 3 times and the results are the following.
| Mac Accelerate framework [sec] | Intel MKL [sec] | |||
| Real time | CPU time | Real time | CPU time | |
| 1 | 14.408 | 104.854 | 11.716 | 46.5299 |
| 2 | 14.811 | 102.439 | 15.101 | 59.2974 |
| 3 | 14.961 | 103.652 | 13.153 | 52.1992 |
Results shows Mac Accelerate framework and Intel MKL show the same performance. Or, MKL is a little bit faster. I don’t know why the CPU time is different…?
More…
I compared MKL with “for loop program”, of which code is the following.
Compile and Run as the following.
> g++-8 -fopenmp -o dgemm_forloop dgemm_forloop.cpp
> for i in 100 1000 2000 3000 4000 5000 6000 7000 8000 9000 10000;
do
./dgemm_forloop $i
done
The result is follow.

MKL is awesome!!
1 Comment