13.07.2015 Views

Intel(R) - Computational and Systems Biology at MIT

Intel(R) - Computational and Systems Biology at MIT

Intel(R) - Computational and Systems Biology at MIT

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Managing Performance <strong>and</strong> Memory 6Techniques to Set the Number of ThreadsYou can employ different techniques to specify the number of threads to use in <strong>Intel</strong> MKL.• Set OpenMP or <strong>Intel</strong> MKL environment variable:— OMP_NUM_THREADS— MKL_NUM_THREADS— MKL_DOMAIN_NUM_THREADS• Call OpenMP or <strong>Intel</strong> MKL function:— omp_set_num_threads()— mkl_set_num_threads()— mkl_domain_set_num_threads().When choosing the appropri<strong>at</strong>e technique, take into account the following rules:• If you employ the OpenMP techniques (OMP_NUM_THREADS <strong>and</strong>omp_set_num_threads()) only, which was the case with earlier <strong>Intel</strong> MKL versions,the library will still respond to them.• The <strong>Intel</strong> MKL threading controls take precedence over the OpenMP techniques.• A subroutine call takes precedence over any environment variables. The exception isthe OpenMP subroutine omp_set_num_threads(), which does not have precedenceover <strong>Intel</strong> MKL environment variables, such as MKL_NUM_THREADS.• The environment variables cannot be used to change run-time behavior in the courseof the run, as they are read only once.Avoiding Conflicts in the Execution EnvironmentThere are situ<strong>at</strong>ions in which conflicts can exist in the execution environment th<strong>at</strong> makethe use of threads in <strong>Intel</strong> MKL problem<strong>at</strong>ic. They are listed here with recommend<strong>at</strong>ions fordealing with these. First, a brief discussion of why the problem exists is appropri<strong>at</strong>e.If the user threads the program using OpenMP directives <strong>and</strong> compiles the program with<strong>Intel</strong>® compilers, <strong>Intel</strong> MKL <strong>and</strong> the program will both use the same threading library. <strong>Intel</strong>MKL tries to determine if it is in a parallel region in the program, <strong>and</strong> if it is, it does notspread its oper<strong>at</strong>ions over multiple threads unless the user specifically requests <strong>Intel</strong> MKLto do so via the MKL_DYNAMIC functionality (see Using Additional Threading Control fordetails). However, <strong>Intel</strong> MKL can be aware th<strong>at</strong> it is in a parallel region only if the threadedprogram <strong>and</strong> <strong>Intel</strong> MKL are using the same threading library. If the user’s program isthreaded by some other means, <strong>Intel</strong> MKL may oper<strong>at</strong>e in multithreaded mode <strong>and</strong> theperformance may suffer due to overuse of the resources.6-3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!