mkl_set_dynamic
mkl_set_dynamic
Enables to dynamically change the number of OpenMP* threads.
Intel® oneAPI Math Kernel Library
Syntax
void
mkl_set_dynamic
(
int
flag
);
Include Files
- mkl.h
Input Parameters
Name | Type | Description |
---|---|---|
flag | int | flag = 0 - Requests disabling dynamic adjustment of the number of threads.flag ≠ 0 - Requests enabling dynamic adjustment of the number of threads. |
Description
This function indicates whether can dynamically change the number of OpenMP threads or should avoid doing this. The setting applies to all functions on all execution threads. This function takes precedence over the
Intel® oneAPI Math Kernel Library
Intel® oneAPI Math Kernel Library
MKL_DYNAMIC
environment variable. Dynamic adjustment of the number of threads is enabled by default. Specifically, may use fewer threads in parallel regions than the number returned by themkl_get_max_threadsfunction. Disabling dynamic adjustment of the number of threads does not ensure that actually uses the specified number of threads, although the library attempts to use that number.
Intel® oneAPI Math Kernel Library
Intel® oneAPI Math Kernel Library
If you call from within an OpenMP parallel region and want to create internal parallel regions, either disable dynamic adjustment of the number of threads or set the thread-local number of threads (seemkl_set_num_threads_local for how to do it).
Intel® oneAPI Math Kernel Library
Example
#include "mkl.h" … mkl_set_num_threads( 8 ); #pragma omp parallel { my_compute_with_mkl(); // Intel MKL uses 1 thread, being called from OpenMP parallel region mkl_set_dynamic( 0 ); // disable adjustment of the number of threads my_compute_with_mkl(); // Intel MKL uses 8 threads }