This topic only applies when targeting Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

Several methods exist to override the default number of threads per core on the coprocessor.

Using the OpenMP* API

The OpenMP* API specification provides the following standard ways to change the desired number of threads on the coprocessor:

  • Calling the function omp_set_num_threads(n) before the omp parallel region

  • Using the clause num_threads with #pragma omp parallel

  • Setting the environment variable OMP_NUM_THREADS=n

For more information, refer to the OpenMP* API Specification at http://www.openmp.org.

Using the Intel® Compiler

In addition to the standard methods that the OpenMP* API specification provides, listed below, you can use the environment variable MIC_ENV_PREFIX to define a custom-prefixed environment variable to control the number of OpenMP* threads on the coprocessor separately from the host CPU. For example, the following environment variable definitions set OMP_NUM_THREADS on both the CPU and the coprocessor, but with different values.

OMP_NUM_THREADS=8
MIC_ENV_PREFIX=ABC
ABC_OMP_NUM_THREADS=124

Direct calls on the coprocessor to APIs in libiomp5.so to establish a specific runtime setting override any setting previously set by a CPU environment variable that is replicated on the coprocessor.

Для получения подробной информации о возможностях оптимизации компилятора обратитесь к нашему Уведомлению об оптимизации.