Intel MKL provides optional threading controls, that is, the environment variables and support functions that are independent of OpenMP. They behave similar to their OpenMP equivalents, but take precedence over them in the meaning that the Intel MKL-specific threading controls are inspected first. By using these controls along with OpenMP variables, you can thread the part of the application that does not call Intel MKL and the library independently of each other.
These controls enable you to specify the number of threads for Intel MKL independently of the OpenMP settings. Although Intel MKL may actually use a different number of threads from the number suggested, the controls will also enable you to instruct the library to try using the suggested number when the number used in the calling application is unavailable.
Sometimes Intel MKL does not have a choice on the number of threads for certain reasons, such as system resources.
Use of the Intel MKL threading controls in your application is optional. If you do not use them, the library will mainly behave the same way as Intel MKL 9.1 in what relates to threading with the possible exception of a different default number of threads.
Subsection "Number of User Threads" in the "Fourier Transform Functions" section of the Intel MKL Reference Manual shows how the Intel MKL threading controls help to set the number of threads for the FFT computation.
The functions take precedence over the respective environment variables.
Therefore, if you want Intel MKL to use a given number of threads in your application and do not want users of your application to change this number using environment variables, set the number of threads by a call to
mkl_set_num_threads(), which will have full precedence over any environment variables being set.
// ******* C language ******* #include <omp.h> #include <mkl.h> ... mkl_set_num_threads ( 1 );
// ******* Fortran language ******* ... call mkl_set_num_threads( 1 )