Use one of the following techniques to change the number of threads to use in Intel MKL:
- Set one of the OpenMP or Intel MKL environment variables:
- OMP_NUM_THREADS
- MKL_NUM_THREADS
- MKL_DOMAIN_NUM_THREADS
- Call one of the OpenMP or Intel MKL functions:
- omp_set_num_threads()
- mkl_set_num_threads()
- mkl_domain_set_num_threads()
When choosing the appropriate technique, take into account the following rules:
- The Intel MKL threading controls take precedence over the OpenMP controls because they are inspected first.
- A function call takes precedence over any environment variables. The exception, which is a consequence of the previous rule, is the OpenMP subroutine
omp_set_num_threads(),
which does not have precedence over Intel MKL environment variables, such as
MKL_NUM_THREADS.
See Using Additional Threading Control for more details.
- You cannot change run-time behavior in the course of the run using the environment variables because they are read only once at the first call to Intel MKL.