Setting Environment Variables on the CPU to Modify the Coprocessor's Execution Environment

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

By default, all environment variables defined in the environment of an executing CPU program are replicated to the coprocessor's execution environment when an offload occurs. You can modify this behavior by defining the environment variable MIC_ENV_PREFIX. When you set MIC_ENV_PREFIX to a specific prefix, then not all CPU environment variables are replicated to the coprocessor, but only those environment variables that begin with the value of the MIC_ENV_PREFIX environment variable. The environment variables set on the coprocessor have the prefix value removed. You thus have independent control of OpenMP*, Intel® Cilk™ Plus, and other execution environments that use common environment variable names.

Setting Multiple Environment Variables on All Coprocessors

You can send multiple variables, each with its own value to all coprocessors.

To do so, use the following form:

mic_prefix_VAR=variable1=value1|variable2=value2|variable3=value3|...

Where variableN is the variable, and valueN is its value.

Specifying a Particular Coprocessor

You can specify a particular coprocessor, which is useful when you have multiple coprocessors installed.

To do so, use the following form:

mic_prefix_card_number_var=value

Where the value of card_number is 0 for the first device, 1 for the second, and so on.

Similarly, when setting multiple environment variables, specify a particular coprocessor, using card_number.

Example: Setting a Single Environment Variables on All Coprocessors

The following environment variable definitions set OMP_NUM_THREADS on both the CPU and all installed coprocessors, but with different values.

MIC_ENV_PREFIX=ABC
OMP_NUM_THREADS=8
ABC_OMP_NUM_THREADS=124

Example: Setting Multiple Environment Variables on All Coprocessors

The following environment variable definition sets X=x and Y=y on all coprocessors.

MIC_ENV_PREFIX=ABC
ABC_VAR=X=x|Y=y

Example: Setting a Single Environment Variables on a Particular Coprocessor

The following environment variable definitions set OMP_NUM_THREADS on both the CPU and the fifth coprocessor installed, but with different values.

MIC_ENV_PREFIX=ABC
OMP_NUM_THREADS=8
ABC_4_OMP_NUM_THREADS=124

Example: Setting Multiple Environment Variables on a Particular Coprocessor

The following environment variable definition sets X=x and Y=y on the fifth coprocessor installed.

MIC_ENV_PREFIX=ABC
ABC_4_VAR=X=x|Y=y
For more complete information about compiler optimizations, see our Optimization Notice.