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

How do I get the current number of MKL threads

Santiago_P_
Beginner
3,239 Views

Hi, I'm trying to make a section of code that runs with a certain number of MKL threads without affecting the number of MKL threads used in other sections of the code. To do this I want to store the status of the MKL_DYNAMIC and the MKL_NUM_THREADS parameters at a given moment in time.

I know that I can use the calls mkl_set_num_threads and mkl_set_dynamic to define the number of threads used by MKL, and that there's a mkl_get_dynamic() call, however there's no mkl_get_num_threads(), there's only a mkl_get_max_threads(). 

Why is it a max and not a num? Is there a way to get the current number of mkl threads? Is it reliable to use the omp_get_num_threads to know this?

Thanks for your help.


 
0 Kudos
1 Solution
VipinKumar_E_Intel
3,239 Views

We have a function called mkl_get_max_threads(), you can find the details here.

http://software.intel.com/en-us/node/471142

 

--Vipin

 

View solution in original post

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
3,239 Views

You can try to use  mkl_set_num_threads( #ofThreads ) routine for this reasons.

0 Kudos
Santiago_P_
Beginner
3,239 Views

Thanks Gennady but I need to know how to get the current number of MKL threads not how to set them.

0 Kudos
VipinKumar_E_Intel
3,240 Views

We have a function called mkl_get_max_threads(), you can find the details here.

http://software.intel.com/en-us/node/471142

 

--Vipin

 

0 Kudos
VipinKumar_E_Intel
3,239 Views

mkl_get_max_threads() reports current maximum number of threads MKL could use and it is the number of cores in the system if nothing was set, or what was set by mkl_set_num_threads. MKL could use a less number of threads also for example if a function call is too small.

 

--Vipin

 

0 Kudos
Santiago_P_
Beginner
3,239 Views

Thank for the link to the details of max_threads Vipin, that information answered my question.

0 Kudos
Reply