• 2020
  • 04/01/2020
  • Public Content
Contents

Intel® MKL
-specific Environment Variables for OpenMP Threading Control

Intel® MKL
provides environment variables and support functions to control
Intel® MKL
threading independently of OpenMP. The
Intel® MKL
-specific threading controls take precedence over their OpenMP equivalents. Use the
Intel® MKL
-specific threading controls to distribute OpenMP threads between
Intel® MKL
and the rest of your program.
Some
Intel® MKL
routines may use fewer OpenMP threads than suggested by the threading controls if either the underlying algorithms do not support the suggested number of OpenMP threads or the routines perform better with fewer OpenMP threads because of lower OpenMP overhead and/or better data locality. Set the
MKL_DYNAMIC
environment variable to
FALSE
or call
mkl_set_dynamic(0)
to use the suggested number of OpenMP threads whenever the algorithms permit and regardless of OpenMP overhead and data locality.
Subsection
"Number of User Threads" in the "Fourier Transform Functions"
section
of the
Intel® MKL
Developer Reference
shows how the
Intel® MKL
threading controls help to set the number of threads for the FFT computation.
The table below lists the
Intel® MKL
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® MKL
to dynamically change the number of OpenMP threads.
OMP_DYNAMIC
Call
mkl_set_num_threads()
to force
Intel® MKL
to use a given number of OpenMP threads and prevent it from reacting to the environment variables
MKL_NUM_THREADS
,
MKL_DOMAIN_NUM_THREADS
, and
OMP_NUM_THREADS
.
The example below shows how to force
Intel® MKL
to use one thread:
// ******* C language ******* #include <mkl.h> ... mkl_set_num_threads ( 1 );
// ******* Fortran language ******* ... call mkl_set_num_threads( 1 )
See the
Intel® MKL
Developer Reference
for the detailed description of the threading control functions, their parameters, calling syntax, and more code examples.
1

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserverd for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804