Developer Guide for Intel® oneAPI Math Kernel Library for Windows*
Calling Intel® oneMKL Functions from Multi-threaded Applications
- This section summarizes typical usage models and available options for calling
-
Intel® oneAPI Math Kernel Library (oneMKL) functions from multi-threaded applications. These recommendations apply to any multi-threading environments: OpenMP*, Intel® Threading Building Blocks,Windows* threads,and others.
Usage model: disable Intel® oneMKL internal threading for the whole application
When used: Intel® oneAPI Math Kernel Library (oneMKL) internal threading interferes with application’s own threading or may slow down the application.
Example: the application is threaded at top level, or the application runs concurrently with other applications.
Options:
Link statically or dynamically with the sequential library
-
- Link with the Single Dynamic Library
-
mkl_rt.lib and select the sequential library using an environment variable or a function call:
Usage model: partition system resources among application threads
When used: application threads are specialized for a particular computation.
Example: one thread solves equations on all cores but one, while another thread running on a single core updates a database.
Linking Options:
Link statically or dynamically with a threading library
-
- Link with the Single Dynamic Library
-
mkl_rt.lib and select a threading library using an environment variable or a function call:
Other Options for OpenMP Threading :
Set the MKL_NUM_THREADS environment variable to a desired number of OpenMP threads for Intel® oneAPI Math Kernel Library (oneMKL) .
Set the MKL_DOMAIN_NUM_THREADS environment variable to a desired number of OpenMP threads for Intel® oneAPI Math Kernel Library (oneMKL) for a particular function domain.
Use if the application threads work with different Intel® oneAPI Math Kernel Library (oneMKL) function domains.
Call mkl_set_num_threads()
Use to globally set a desired number of OpenMP threads for Intel® oneAPI Math Kernel Library (oneMKL) at run time.
Call mkl_domain_set_num_threads() .
Use if at some point application threads start working with different Intel® oneAPI Math Kernel Library (oneMKL) function domains.
Call mkl_set_num_threads_local() .
Use to set the number of OpenMP threads for Intel® oneAPI Math Kernel Library (oneMKL) called from a particular thread.
Set the environment variable OMP_NESTED=TRUE , or alternatively call omp_set_nested(1) , to enable OpenMP nested parallelism.
Set the environment variable MKL_DYNAMIC=FALSE , or alternatively call mkl_set_dynamic(0) , to prevent Intel® oneAPI Math Kernel Library (oneMKL) from dynamically reducing the number of OpenMP threads in nested parallel regions.
Product and Performance Information |
|---|
Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex . Notice revision #20201201 |