Developer Guide for Intel® oneAPI Math Kernel Library for Linux*
Intel® oneMKL -specific Environment Variables for OpenMP Threading Control
Intel® oneAPI Math Kernel Library (oneMKL) provides environment variables and support functions to control Intel® oneAPI Math Kernel Library (oneMKL) threading independently of OpenMP. The Intel® oneAPI Math Kernel Library (oneMKL) -specific threading controls take precedence over their OpenMP equivalents. Use the Intel® oneAPI Math Kernel Library (oneMKL) -specific threading controls to distribute OpenMP threads between Intel® oneAPI Math Kernel Library (oneMKL) and the rest of your program.
The table below lists the Intel® oneAPI Math Kernel Library (oneMKL) environment variables for threading control, their equivalent functions, and OMP counterparts:
Environment Variable |
Support Function |
Comment |
Equivalent OpenMP* Environment Variable |
|---|---|---|---|
MKL_NUM_THREADS |
mkl_set_num_threads mkl_set_num_threads_local |
Suggests the number of OpenMP threads to use. |
OMP_NUM_THREADS |
MKL_DOMAIN_NUM_ THREADS |
mkl_domain_set_num_threads |
Suggests the number of OpenMP threads for a particular function domain. |
|
MKL_DYNAMIC |
mkl_set_dynamic |
Enables Intel® oneAPI Math Kernel Library (oneMKL) to dynamically change the number of OpenMP threads. |
OMP_DYNAMIC |
The example below shows how to force Intel® oneAPI Math Kernel Library (oneMKL) to use one thread:
// ******* C language *******
#include <mkl.h>
...
mkl_set_num_threads ( 1 );
// ******* Fortran language *******
...
call mkl_set_num_threads( 1 )