Threading Control Functions

Intel® MKL provides optional threading control functions that take precedence over OpenMP* environment variable settings with the same purpose (see Intel® MKL User's Guide for details).

These functions enable you to specify the number of threads for Intel MKL independently of the OpenMP* settings and takes precedence over them. Although Intel MKL may actually use a different number of threads from the number suggested, the controls also enable you to instruct the library to try using the suggested number when the number used in the calling application is unavailable.

See the following examples of Fortran and C usage:

Fortran Usage

call mkl_set_num_threads( foo )
ierr = mkl_domain_set_num_threads( num, MKL_DOMAIN_BLAS )
call mkl_set_dynamic ( 1 )
num = mkl_get_max_threads()
num = mkl_domain_get_max_threads( MKL_DOMAIN_BLAS );
ret = mkl_get_dynamic()

C Usage

#include "mkl.h"  // Mandatory to make these definitions work!
mkl_set_num_threads(num);
return_code = mkl_domain_set_num_threads( num, MKL_DOMAIN_FFT );
mkl_set_dynamic( 1 );
num = mkl_get_max_threads();
num = mkl_domain_get_max_threads( MKL_DOMAIN_FFT );
return_code = mkl_get_dynamic();

Note iconNote

Always remember to add #include "mkl.h" to use the C usage syntax.


Submit feedback on this help topic