Parallel Programming Guide for HP-UX Systems

Data privatization
Privatizing loop variables
Chapter 6 111
Privatizing loop variables
This section describes the following directives and pragmas associated
with privatizing loop variables:
loop_private
save_last
loop_private
The loop_private directive and pragma declares a list of variables
and/or arrays private to the immediately following Fortran DO or C for
loop. loop_private array dimensions must be identifiable at
compile-time.
The compiler assumes that data objects declared to be loop_private
have no loop-carried dependences with respect to the parallel loops in
which they are used. If dependences exist, they must be handled
manually using the synchronization directives and techniques.
Each parallel thread of execution receives a private copy of the
loop_private data object for the duration of the loop. No starting values
are assumed for the data. Unless a save_last directive or pragma is
specified, no ending value is assumed. If a loop_private data object is
referenced within an iteration of the loop, it must be assigned a value
previously on that same iteration.
The form of this directive and pragma is shown in Table 6-2.
where
namelist is a comma-separated list of variables and/or arrays
that are to be private to the immediately following loop.
namelist cannot contain structures, dynamic arrays,
allocatable arrays, or automatic arrays.
Table 6-2 Form of loop_private directive and pragma
Language Form
Fortran C$DIR LOOP_PRIVATE(namelist)
C #pragma _CNX loop_private(namelist)