9.11. Environment variables

This section explains the OpenMP C and C++ API environment variables that control the execution of parallel code. The names of environment variables must be uppercase. The values assigned to them are case insensitive and may have leading and trailing white space. Modifications to the values after the program has started are ignored. The environment variables are as follows:

OMP_SCHEDULESets the run-time schedule type and chunk size.
OMP_NUM_THREADSSets the number of threads to use during execution.
OMP_DYNAMICEnables or disables dynamic adjustment of the number of threads.
OMP_NESTEDEnables or disables nested parallelism.

For further information about these environment variables, please refer to the “Parallel Processing Support” section in the VisualAge C++ for AIX Compiler Reference, SC09-4959.

9.11.1. OMP_SCHEDULE

OMP_SCHEDULE applies only to for and parallel for directives that have the schedule type run time. The schedule type and chunk size for all such loops can be set at run time by setting this environment variable to any of the recognized schedule types and to an optional chunk_size.

For for and parallel for directives that have a schedule type other than run time, OMP_SCHEDULE is ignored. The default value for this environment variable is implementation-defined. If the optional chunk_size is set, the value must be positive. If chunk_size is not set, a value of 1 is assumed, except in the case of a static schedule. For a static schedule, the default chunk size is set to the loop iteration space divided by the number of threads applied to the loop.

The syntax of OMP_SCHEDULE is:

OMP_SCHEDULE=algorithm
					

where algorithm is one of the following:

  • dynamic[,N]

  • guided[,N]

  • runtime

  • static[,N]

If specified, the value of N must be an integer value of 1 or greater.

9.11.2. OMP_NUM_THREADS

The OMP_NUM_THREADS environment variable sets the default number of threads to use during execution, unless that number is explicitly changed by calling the omp_set_num_threads library routine or by an explicit num_threads clause on a parallel directive.

Its effect depends upon whether dynamic adjustment of the number of threads is enabled. If no value is specified for the OMP_NUM_THREADS environment variable, or if the value specified is not a positive integer, or if the value is greater than the maximum number of threads the system can support, the number of threads to use is implementation-defined. On AIX, it depends on the number of available processors.

The syntax of OMP_NUM_THREADS is:

OMP_NUM_THREADS=N
					

Where N is the number of parallel threads requested, which must be a positive integer. The number can be overridden during program execution by calling the omp_set_num_threads() run-time library function.

9.11.3. OMP_DYNAMIC

The OMP_DYNAMIC environment variable enables or disables dynamic adjustment of the number of threads available for execution of parallel regions. The setting of this environment variable can be overridden by calling the omp_set_dynamic() run-time library function.

The syntax of OMP_DYNAMIC is:

OMP_DYNAMIC=[TRUE | FALSE]

If set to TRUE, the number of threads that are used for executing parallel regions may be adjusted by the run-time environment to best utilize system resources. If set to FALSE, dynamic adjustment is disabled. The default condition is implementation-defined.

9.11.4. OMP_NESTED

The OMP_NESTED environment variable enables or disables nested parallelism. The setting of this environment variable can be overridden by calling the omp_set_nested() run-time library function.

The syntax of OMP_NESTED is:

OMP_NESTED=[TRUE | FALSE]

If set to TRUE, nested parallelism is enabled; if it is set to FALSE, nested parallelism is disabled. The default value is FALSE.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset