Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Matthias_L_
Beginner
256 Views

Multithreading (BLAS sgemm)

Jump to solution

Dear Forum,

I am trying to make MKL accelerate a matrix multiplication for me. It works, but MKL insists on doing it with a single thread. I played around a bit. But regardless of what I do - even when multiplying two randomly initialized 10000x10000 matrices - MKL does not use multiple threads. Am I missing something?

Function:

BLAS sgemm, via libmkl_rt.so

 

Environment settings:

MKL_NUM_THREADS=8; export MKL_NUM_THREADS
OMP_NUM_THREADS=8; export OMP_NUM_THREADS
MKL_DYNAMIC=FALSE; export MKL_DYNAMIC
OMP_DYNAMIC=FALSE; export OMP_DYNAMIC
MKL_DOMAIN_NUM_THREADS=MKL_DOMAIN_ALL,8; export MKL_DOMAIN_NUM_THREADS
OMP_DOMAIN_NUM_THREADS=MKL_DOMAIN_ALL,8; export OMP_DOMAIN_NUM_THREADS

 

Machine:

LinuxMint 17.2, Kernel: 3.19.0-26, CPU: 4th gen. i7, HT activated in BIOS

 

0 Kudos
1 Solution
Ying_H_Intel
Employee
256 Views

Hi Matthias L.

Do you have any result if MKL_VERBOSE=1 ?   Or are you calling sgemm in one multi-thread application? 

In some of situation, the MKL may not spawns threads as external threads. 

https://software.intel.com/en-us/articles/recommended-settings-for-calling-intelr-mkl-routines-from-...

Best Regards,

Ying 

 

View solution in original post

4 Replies
Roman_D_Intel1
Employee
256 Views

Hi Matthias, how do you check that MKL runs single-threaded? Also, can you please show your LD_LIBRARY_PATH?

Usually setting OMP_NUM_THREADS is not even necessary since when it is not set, the Intel OpenMP library would use all the CPUs in the process CPU mask which is set to all CPUs by default.

Gennady_F_Intel
Moderator
256 Views

please set the environment variable MKL_VERBOSE=1 to check how many threads has been used while ?gemm was called.

Ying_H_Intel
Employee
257 Views

Hi Matthias L.

Do you have any result if MKL_VERBOSE=1 ?   Or are you calling sgemm in one multi-thread application? 

In some of situation, the MKL may not spawns threads as external threads. 

https://software.intel.com/en-us/articles/recommended-settings-for-calling-intelr-mkl-routines-from-...

Best Regards,

Ying 

 

View solution in original post

Matthias_L_
Beginner
256 Views

Thanks for your comments and sorry that it took so long. I got it working properly now. There was some conflict with the LD_LBIRARY_PATH. Instead the system loaded the another BLAS implementation that I had installed. Why that was I cannot tell. I can hereby confirm that the MK_VERBOSE is very helpful for diagnosing issues. And that

MKL_NUM_THREADS=8; export MKL_NUM_THREADS

OMP_NUM_THREADS=8; export OMP_NUM_THREADS

MKL_DYNAMIC=FALSE; export MKL_DYNAMIC

OMP_DYNAMIC=FALSE; export OMP_DYNAMIC

produces the right results one would expect (if one loads the right runtime library).

~Matthias

Reply