Avoiding Conflicts in the Execution Environment
Certain situations can cause conflicts in the execution environment that make the use of threads in
problematic. This section briefly discusses why these problems exist and how to avoid them.
Intel® oneAPI Math Kernel Library
If your program is parallelized by means other than Intel® OpenMP* run-time library (RTL) and Intel® Threading Building Blocks (oneTBB) RTL, several calls to
may operate in a multithreaded mode at the same time and result in slow performance due to overuse of machine resources.
Intel® oneAPI Math Kernel Library
The following table considers several cases where the conflicts may arise and provides recommendations depending on your threading model:
Threading model
| Discussion
|
---|---|
You parallelize the program
using the technology other than Intel OpenMP and oneTBB
(for example:
pthreads macOS* ).
| If more than one thread calls
Intel® oneAPI Math Kernel Library Intel® oneAPI Math Kernel Library |
You parallelize the program using OpenMP directives and/or pragmas and compile the program using a non-Intel compiler.
| To avoid simultaneous activities of multiple threading RTLs, link the program against the
(see
on how to do this). If this is not possible, use
Intel® oneAPI Math Kernel Library Intel® oneAPI Math Kernel Library lib mkl_sequential. a or
lib mkl_sequential. dylib (see
Appendix C: Directory Structure in Detail).
|
You thread the program using oneTBB threading technology and compile the program using a non-Intel compiler.
| To avoid simultaneous activities of multiple threading RTLs, link the program against the
Intel® oneAPI Math Kernel Library Intel® oneAPI Math Kernel Library lib mkl_sequential .a or
lib mkl_sequential .dylib (see
Appendix C: Directory Structure in Detail).
|
You run multiple programs calling
Intel® oneAPI Math Kernel Library | The threading RTLs from different programs you run may place a large number of threads on the same processor on the system and therefore overuse the machine resources.
In this case, one of the solutions is to set the number of threads to one by any of the available means (see
Techniques to Set the Number of Threads).
|
Using the
from parallel user threads may result in a race condition that impacts the performance of the application because these functions operate on internal control variables that are global, that is, apply to all threads. For example, if parallel user threads call these functions to set different numbers of threads for the same function domain, the number of threads actually set is unpredictable. To avoid this kind of data races, use the Developer Reference for the function description).
mkl_set_num_threads
and
mkl_domain_set_num_threads
functions to control parallelism of
Intel® oneAPI Math Kernel Library
mkl_set_num_threads_local
function (see the "Support Functions"
section
in the
Intel® oneAPI Math Kernel Library
Product and Performance Information
|
---|
Performance varies by use, configuration and other factors. Learn more at
www.Intel.com/PerformanceIndex.
Notice revision #20201201
|