Developer Guide

Developer Guide for Intel® oneAPI Math Kernel Library macOS*

ID 766688
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

MKL_DYNAMIC

The MKL_DYNAMICenvironment variable enables Intel® oneAPI Math Kernel Library to dynamically change the number of threads.

The default value of MKL_DYNAMIC is TRUE, regardless of OMP_DYNAMIC, whose default value may be FALSE.

When MKL_DYNAMIC is TRUE,Intel® oneAPI Math Kernel Library may use fewer OpenMP threads than the maximum number you specify.

For example, MKL_DYNAMIC set to TRUE enables optimal choice of the number of threads in the following cases:

  • If the requested number of threads exceeds the number of physical cores (perhaps because of using the Intel® Hyper-Threading Technology), Intel® oneAPI Math Kernel Library scales down the number of OpenMP threads to the number of physical cores.

  • If you are able to detect the presence of a message-passing interface (MPI), but cannot determine whether it has been called in a thread-safe mode, Intel® oneAPI Math Kernel Library runs one OpenMP thread.

When MKL_DYNAMIC is FALSE, Intel® oneAPI Math Kernel Library uses the suggested number of OpenMP threads whenever the underlying algorithms permit.For example, if you attempt to do a size one matrix-matrix multiply across eight threads, the library may instead choose to use only one thread because it is impractical to use eight threads in this event.

If Intel® oneAPI Math Kernel Library is called from an OpenMP parallel region in your program, Intel® oneAPI Math Kernel Library uses only one thread by default. If you want Intel® oneAPI Math Kernel Library to go parallel in such a call, link your program against an OpenMP threading RTL supported by Intel® oneAPI Math Kernel Library and set the environment variables:

  • OMP_NESTED to TRUE
  • OMP_DYNAMIC and MKL_DYNAMIC to FALSE
  • MKL_NUM_THREADS to some reasonable value

With these settings, Intel® oneAPI Math Kernel Library usesMKL_NUM_THREADS threads when it is called from the OpenMP parallel region in your program.

In general, set MKL_DYNAMIC to FALSEonly under circumstances that Intel® oneAPI Math Kernel Library is unable to detect, for example, to use nested parallelism where the library is already called from a parallel section.

Product and Performance Information

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.

Notice revision #20201201