Download Intel(R) Math Kernel Library for Linux* User's Guide

Transcript
Managing Performance and Memory
6
Avoiding Conflicts in the Execution Environment
There are situations in which conflicts can exist in the execution environment that make
the use of threads in Intel MKL problematic. They are listed here with recommendations for
dealing with these. First, a brief discussion of why the problem exists is appropriate.
If the user threads the program using OpenMP directives and compiles the program with
Intel® compilers, Intel MKL and the program will both use the same threading library. Intel
MKL tries to determine if it is in a parallel region in the program, and if it is, it does not
spread its operations over multiple threads unless the user specifically requests Intel MKL
to do so via the MKL_DYNAMIC functionality (see Using Additional Threading Control for
details). However, Intel MKL can be aware that it is in a parallel region only if the threaded
program and Intel MKL are using the same threading library. If the user’s program is
threaded by some other means, Intel MKL may operate in multithreaded mode and the
performance may suffer due to overuse of the resources.
Here are several cases with recommendations depending on the threading model you
employ:
Table 6-1
How to avoid conflicts in the execution environment for your threading
model
Threading model
Discussion
You thread the program using OS threads
(pthreads on Linux*).
If more than one thread calls the library, and the
function being called is threaded, it may be
important that you turn off Intel MKL threading. Set
the number of threads to one by any of the available
means (see Techniques to Set the Number of
Threads).
You thread the program using OpenMP directives
and/or pragmas and compile the program using a
compiler other than a compiler from Intel.
This is more problematic in that setting of
OMP_NUM_THREADS in the environment affects both
the compiler's threading library and libguide
(libiomp). In this case, you should try to choose
the Threading layer library that matches the layered
Intel MKL with the OpenMP compiler you employ (see
Linking with Threading Libraries on how to do this).
If this is impossible, the sequential version of Intel
MKL can be used as the Threading layer. To do this,
you should link with the appropriate Threading layer
library: libmkl_sequential.a or
libmkl_sequential.so (see the High-level
Directory Structure section in chapter 3).
6-3