Chapter 3 Implementation-Defined Behaviors
This chapter notes specific behaviors in the OpenMP 3.0 specification
that are implementation
dependent.
3.1 Task
Scheduling Points
Task scheduling points in untied task regions occur at the same points
as in tied task regions. So within untied task regions, task scheduling points
only appear in the following:
-
encountered task constructs
-
encountered taskwait constructs
-
encountered barrier directives
-
implicit barrier regions
-
at the end of the untied task region
3.2 Memory Model
There is no guarantee that memory accesses by multiple threads to the
same variable without synchronization are atomic with respect to each other.
Several implementation-dependent and application-dependent factors affect
whether accesses are atomic or not. Some variables might be larger than the
largest atomic memory operation on the target platform. Some variables might
be mis-aligned or of unknown alignment and the compiler or the run-time system
may need to use multiple loads/stores to access the variable. Sometimes there
are faster code sequences that use more loads/stores.
3.3 Internal Control Variables
The following internal control variables are defined by the implementation:
-
nthreads-var: Controls the number of
threads requested for encountered parallel regions. The initial value of nthreads-var is 1.
-
dyn-var: Controls whether dynamic adjustment
of the number of threads is enabled for encountered parallel regions. The
initial value of dyn-var is TRUE (that
is, dynamic adjustment is enabled).
-
run-sched-var: Controls the schedule
that the runtime schedule clause uses for loop regions. The initial value
of run-sched-var is static with no
chunk size.
-
def-sched-var: Controls the implementation
defined default scheduling of loop regions. The initial value of def-sched-var is static with no chunk size.
-
stacksize-var: Controls the stack size
for threads that the OpenMP implementation creates. The initial value of stacksize-var is 4 MegaBytes for 32-bit applications and 8 MegaBytes
for 64-bit applications.
-
wait-policy-var: Controls the desired
behavior of waiting threads. The initial value of wait-policy-var is PASSIVE.
-
thread-limit-var: Controls the maximum
number of threads participating in the OpenMP program. The initial value of
thread-limit-var is 1024.
-
max-active-levels-var: Controls the maximum
number of nested active parallel regions. The initial value of max-active-levels-var is 4.
3.4 Dynamic Adjustment of Threads
The implementation provides the ability to dynamically adjust the number
of threads. Dynamic adjustment is enabled by default. Set the OMP_DYNAMIC environment variable to FALSE, or call
the omp_set_dynamic() routine with the appropriate
argument, to disable dynamic adjustment.
When a thread encounters a parallel construct, the number of threads
delivered by this implementation is determined according to Algorithm 2.1
pp. 35-36 in the OpenMP 3.0 Specification. In exceptional situations, such
as when there is a lack of system resources, the number of threads supplied
will be less than described in Algorithm 2.1. In these situations, if SUNW_MP_WARN is set to TRUE or a callback
function is registered via a call to sunw_mp_register_warn(),
a warning message will be issued.
3.5 Loop
Directive
The integer type used to compute the iteration count of a collapsed
loop is long.
The effect of the schedule(runtime) clause when
the run-sched-var internal control variable is set to auto is static with no chunk size.
3.6 Constructs
3.6.1 SECTIONS
The structured blocks in the sections construct are assigned to the
threads in the team in a static with no chunk size fashion, so that each thread
gets an approximately equal number of consecutive structured blocks.
3.6.2 SINGLE
The first thread to encounter the single construct
will execute the construct.
3.6.3 ATOMIC
The implementation replaces all atomic directives
by enclosing the target statement with a special, named critical construct.
This will enforce exclusive access between all atomic regions in the program,
whether or not these regions update the same or different storage locations.
3.7 Routines
3.7.1 omp_set_schedule
The behavior for the Sun-specific sunw_mp_sched_reserved schedule
is the same as static with no chunk size.
3.7.2 omp_set_max_active_levels
If omp_set_max_active_levels()is called from
within an active parallel region, then the call will be ignored. A warning
message will be issued if SUNW_MP_WARN is set to TRUE or a callback function is registered by a call to sunw_mp_register_warn().
If the argument to omp_set_max_active_levels() is
not a non-negative integer, then the call will be ignored. A warning message
will be issued if SUNW_MP_WARN is set to TRUE or
a callback function is registered by a call to sunw_mp_register_warn().
3.7.3 omp_get_max_active_levels
omp_get_max_active_levels() can be called from
anywhere in the program. The call will return the value of the max-active-levels-var internal control variable.
3.8 Environment Variables
|
Variable Name
|
Implementation
|
|
OMP_SCHEDULE
|
If the schedule type specified for the OMP_SCHEDULE is
not one of the valid types (static, dynamic, guided, or auto), then the environment
variable will be ignored, and the default schedule (static with
no chunk size) will be used. A warning message will be issued if SUNW_MP_WARN is set to TRUE or a callback function is registered
by a call to sunw_mp_register_warn().
If the schedule type specified for the OMP_SCHEDULE environment
variable is static, dynamic,
or guided, but the chunk specified size is a negative
integer, then the chunk size used will be as follows: For static,
there will be no chunk size . For dynamic and guided, the chunk size will be 1. A warning message will be issued if SUNW_MP_WARN is set to TRUE or a callback function
is registered by a call to sunw_mp_register_warn().
|
|
OMP_NUM_THREADS
|
If the value of the variable is not a positive integer, then the environment
variable will be ignored and a warning message will be issued if SUNW_MP_WARN is set to TRUE or a callback function is registered
by a call to sunw_mp_register_warn().
If the value of the variable is greater than the number of threads the
implementation can support, the following actions are taken:
- if dynamic adjustment of the number of threads
is enabled, then the number of threads will be reduced and a warning message
will be issued if SUNW_MP_WARN is set to TRUE or
a callback function is registered by a call to sunw_mp_register_warn().
- if, on the other hand, dynamic adjustment of the number of threads
is disabled, then an error message will be issued and the program will stop.
|
|
OMP_DYNAMIC
|
If the value specified for OMP_DYNAMIC is neither TRUE nor FALSE, then the value will be ignored,
and the default value TRUE will be used. A warning message
will be issued if SUNW_MP_WARN is set to TRUE or
a callback function is registered by a call to sunw_mp_register_warn().
|
|
OMP_NESTED
|
If the value specified for OMP_NESTED is neither TRUE nor FALSE, then the value will be ignored,
and the default value FALSE will be used. A warning message
will be issued if SUNW_MP_WARN is set to TRUE or
a callback function is registered by a call to sunw_mp_register_warn().
|
|
OMP_STACKSIZE
|
If the value given for OMP_STACKSIZE does not
conform to the specified format, then the value will be ignored, and the default
value (4 Megabytes for 32-bit applications, and 8 Megabytes for 64-bit applications)
will be used. A warning message will be issued if SUNW_MP_WARN is
set to TRUE or a callback function is registered by a call
to sunw_mp_register_warn().
|
|
OMP_WAIT_POLICY
|
The ACTIVE behavior for a thread is spin.
The PASSIVE behavior for a thread is sleep,
after possibly spinning for a while.
|
|
OMP_MAX_ACTIVE_LEVELS
|
If the value specified for OMP_MAX_ACTIVE_LEVELS is
not a nonnegative integer, then the value will be ignored, and the default
value (4) will be used. A warning message will be issued if SUNW_MP_WARN is set to TRUE or a callback function is registered
by a call to sunw_mp_register_warn().
|
|
OMP_THREAD_LIMIT
|
If the value specified for OMP_THREAD_LIMIT is
not a positive integer, then the value will be ignored, and the default value
(1024) will be used. A warning message will be issued if SUNW_MP_WARN is set to TRUE or a callback function is registered
by a call to sunw_mp_register_warn().
|
3.9 Fortran Issues
The following apply to Fortran only.
3.9.1 THREADPRIVATE Directive
If the conditions for values of data in the threadprivate objects of
threads (other than the initial thread) to persist between two consecutive
active parallel regions do not all hold, then the allocation status of an
allocatable array in the second region might be "not currently allocated".
3.9.2 SHARED Clause
Passing a shared variable to a non-intrinsic procedure may result in
the value of the shared variable being copied into temporary storage before
the procedure reference, and back out of the temporary storage into the actual
argument storage after the procedure reference. This copying into and out
of temporary storage can occur only if conditions a, b, and c in OpenMP 3.0
Specification, section 2.9.3.2 on p. 88 hold,namely: .
-
The actual argument is one of the following:
-
A shared variable
-
A subobject of a shared variable
-
An object associated with a shared variable
-
An object associated with a subobject of a shared variable
-
The actual argument is also one of the following:
-
The associated dummy argument for this actual argument is
an explicit-shape array or an assumed-size array.
3.9.3 Runtime Library Definitions
Both the include file omp_lib.h and the module
file omp_lib are provided in the implementation.
On Solaris platforms, the OpenMP runtime library routines that take
an argument are extended with a generic interface so arguments of different
Fortran KIND types can be accommodated.