Developer Guide

Developer Guide for Intel® oneAPI Math Kernel Library Windows*

ID 766692
Date 7/13/2023
Public

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

Document Table of Contents

Improving Performance with Threading

Intel® oneAPI Math Kernel Library (oneMKL) is extensively parallelized. SeeOpenMP* Threaded Functions and Problems and Functions Threaded with Intel® Threading Building Blocks for lists of threaded functions and problems that can be threaded.

Intel® oneAPI Math Kernel Library (oneMKL) isthread-safe, which means that all Intel® oneAPI Math Kernel Library (oneMKL) functions (except the LAPACK deprecated routine?lacon)work correctly during simultaneous execution by multiple threads. In particular, any chunk of threaded Intel® oneAPI Math Kernel Library (oneMKL) code provides access for multiple threads to the same shared data, while permitting only one thread at any given time to access a shared piece of data. Therefore, you can call Intel® oneAPI Math Kernel Library (oneMKL) from multiple threads and not worry about the function instances interfering with each other.

If you are using OpenMP* threading technology, you can use the environment variable OMP_NUM_THREADSto specify the number of threads or the equivalent OpenMP run-time function calls. Intel® oneAPI Math Kernel Library (oneMKL) also offers variables that are independent of OpenMP, such asMKL_NUM_THREADS, and equivalent Intel® oneAPI Math Kernel Library (oneMKL) functions for thread management. The Intel® oneAPI Math Kernel Library (oneMKL) variables are always inspected first, then the OpenMP variables are examined, and if neither is used, the OpenMP software chooses the default number of threads.

By default, Intel® oneAPI Math Kernel Library (oneMKL) uses the number ofOpenMP threads equal to the number of physical cores on the system.

If you are using the Intel TBB threading technology, the OpenMP threading controls, such as the OMP_NUM_THREADS environment variable or MKL_NUM_THREADS function, have no effect. Use the Intel TBB application programming interface to control the number of threads.

To achieve higher performance, set the number of threads to the number of processors or physical cores, as summarized in Techniques to Set the Number of Threads.

Product and Performance Information

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

Notice revision #20201201