+O[no]openmp Command Line Option

The +Oopenmp option is accepted at all optimization levels. The +Oopenmp option enables the recognition of OpenMP pragmas. Using the +Onoopenmp option will ignore all OpenMP directives silently.

See Chapter 3: “Pragma Directives and Attributes” (page 96) for more information on OpenMP pragmas.

_OPENMP Macro

The _OPENMP macro name is defined by OpenMP compliant implementation as the decimal constant 200203. This macro must not be the subject of #define or #undef preprocessing directive. Following is an example of conditional compilation:

#ifdef _OPENMP

iam = omp_get_thread_num() + index; #endif

Environment Variables in OpenMP

The OpenMP environment variables recognized by HP aC++ compiler control the execution of parallel code. Note that the environment variable names are case sensitive and they must be in uppercase.

The following environment variables are available in HP aC++ compiler:

OMP_SCHEDULE

OMP_NUM_THREADS

OMP_DYNAMIC

OMP_NESTED

OMP_SCHEDULE

export OMP_SCHEDULE="kind[,chunk_size]"

setenv OMP_SCHEDULE "kind[,chunk_size]"

where, kind is either of of static, dynamic, or guided.

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

The default value of the environment variable is a static schedule with a chunk_size of 1. 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 for static schedule. For a static schedule, the default chunk_size is set to the loop iteration space divided by a number of threads applied to the loop.

NOTE: OMP_SCHEDULE is ignored for for and parallel for directives that have a schedule type other than runtime.

OMP_NUM_THREADS

export OMP_NUM_THREADS=value

setenv OMP_NUM_THREADS value

The OMP_NUM_THREADS environment variable sets the default number of threads to use during execution. The value of OMP_NUM_THREADS must be a positive integer. Its effect depends on whether dynamic adjustment of the number of threads is enabled, and its interaction with the omp_set_num_threads library routine and any num_threads clause on a parallel directive.

The default value is the number of physical processors on the system.

Parallel Programming Using OpenMP 169