13.07.2015 Views

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

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

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

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

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

6 <strong>Intel</strong>® <strong>Math</strong> <strong>Kernel</strong> <strong>Library</strong> User’s <strong>Guide</strong>The example below illustrates the use of the <strong>Intel</strong> MKL function mkl_set_num_threads()to set one thread.Example 6-2Setting the Number of Threads to One// ******* C language *******#include #include …mkl_set_num_threads ( 1 );// ******* Fortran language *******…call mkl_set_num_threads( 1 )The section further explains the <strong>Intel</strong> MKL environment variables <strong>for</strong> threading control. Seethe <strong>Intel</strong> MKL Reference Manual <strong>for</strong> the detailed description of the threading controlfunctions, their parameters, calling syntax, and more code examples.MKL_DYNAMICThe MKL_DYNAMIC environment variable enables <strong>Intel</strong> MKL to dynamically change thenumber of threads.The default value of MKL_DYNAMIC is TRUE, regardless of OMP_DYNAMIC, whose defaultvalue may be FALSE.When MKL_DYNAMIC is TRUE, <strong>Intel</strong> MKL tries to use what it considers the best number ofthreads, up to the maximum number you specify.For example, MKL_DYNAMIC set to TRUE enables optimal choice of the number of threads inthe following cases:• If the requested number of threads exceeds the number of physical cores (perhapsbecause of hyper-threading), and MKL_DYNAMIC is not changed from its default valueof TRUE, <strong>Intel</strong> MKL will scale down the number of threads to the number of physicalcores.• If you are able to detect the presence of MPI, but cannot determine if it has beencalled in a thread-safe mode (it is impossible to detect this with MPICH 1.2.x, <strong>for</strong>instance), and MKL_DYNAMIC has not been changed from its default value of TRUE,<strong>Intel</strong> MKL will run one thread.When MKL_DYNAMIC is FALSE, <strong>Intel</strong> MKL tries not to deviate from the number of threadsthe user requested. However, setting MKL_DYNAMIC=FALSE does not ensure that <strong>Intel</strong> MKLwill use the number of threads that you request. The library may have no choice on this6-10

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

Saved successfully!

Ooh no, something went wrong!