Developer Reference for Intel® oneAPI Math Kernel Library for Fortran
mkl_set_dynamic
Enables Intel® oneAPI Math Kernel Library (oneMKL) to dynamically change the number of OpenMP* threads.
Syntax
callmkl_set_dynamic ( flag )
Include Files
Include file: mkl.fi
Module (compiled): mkl_service.mod
Module (source): mkl_service.f90
Input Parameters
Name |
Type |
Description |
|---|---|---|
flag |
INTEGER |
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 Intel® oneMKL can dynamically change the number of OpenMP threads or should avoid doing this. The setting applies to all Intel® oneMKL functions on all execution threads. This function takes precedence over the MKL_DYNAMIC environment variable.
Dynamic adjustment of the number of threads is enabled by default. Specifically, Intel® oneMKL may use fewer threads in parallel regions than the number returned by the mkl_get_max_threads function. Disabling dynamic adjustment of the number of threads does not ensure that Intel® oneMKL actually uses the specified number of threads, although the library attempts to use that number.
use mkl_service
! ...
call mkl_set_num_threads( 8 )
!$omp parallel
call my_compute_with_mkl ! Intel MKL uses 1 thread, being called from OpenMP parallel region
call mkl_set_dynamic(0) ! disable adjustment of the number of threads
call my_compute_with_mkl ! Intel MKL uses 8 threads
!$omp end parallel