Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6956 Discussions

MKL routines within OMP parallel loop

YW
Beginner
667 Views

Hi,

How many threads will an MKL routine (e.g. cblas_sgemm) launches when that routine is included within an OMP parallel loop? Is it the same in both Xeon and Xeon Phi?

Thanks!

0 Kudos
4 Replies
VipinKumar_E_Intel
667 Views

Hi,

By default, only 1 thread will be created for MKL, if it's an openmp parallel region. If you want MKL to use multiple threads, you can set MKL_DYNAMIC=false.

--Vipin

0 Kudos
YW
Beginner
667 Views

Vipin Kumar E K (Intel) wrote:

Hi,

By default, only 1 thread will be created for MKL, if it's an openmp parallel region. If you want MKL to use multiple threads, you can set MKL_DYNAMIC=false.

--Vipin

Thanks! It seems that the number of running threads is easy to go wild if MKL_NYNAMIC is set to be false, right? Is there a way to control the number of threads (>1 but smaller than a certain number) an MKL routines could launch?

0 Kudos
VipinKumar_E_Intel
667 Views

 Please refer https://software.intel.com/en-us/node/528380 for more details on various api functions and env. variables to set for calling MKL in a nested region.

--Vipin

 

0 Kudos
Jeongnim_K_Intel1
667 Views

You can also control the threads by setting these. Assuming that the user openmp regions use 60 threads and 4 threads should run dgemm (any mkl function), set these variables at the run time.

#enable nested OpenMP
export OMP_NESTED=TRUE
export OMP_NUM_THREADS=60,4

#OpenMP 4 placement: 4 threads per core do dgemm
export OMP_PLACES=threads
export OMP_PROC_BIND=spread,close

#Enable HOT TEAMS: Intel compiler 15 update 1
export KMP_HOT_TEAMS_MAX_LEVEL=2
export KMP_HOT_TEAMS_MODE=1

 

0 Kudos
Reply