Parallel Programming Guide for HP-UX Systems

Data privatization
Privatizing task variables
Chapter 6118
Privatizing task variables
Task privatization is manually speciļ¬ed using the task_private
directive and pragma. task_private declares a list of variables and/or
arrays private to the immediately following tasks. It serves the same
purpose for parallel tasks that loop_private serves for loops and
parallel_private serves for regions.
task_private
The task_private directive must immediately precede, or appear on the
same line as, its corresponding begin_tasks directive. The compiler
assumes that data objects declared to be task_private have no
dependences between the tasks in which they are used. If dependences
exist, you must handle them manually using the synchronization
directives and techniques.
Each parallel thread of execution receives a private copy of the
task_private data object for the duration of the tasks. No starting or
ending values are assumed for the data. If a task_private data object is
referenced within a task, it must have been previously assigned a value
in that task.
The form of this directive and pragma is shown in Table 6-4.
where
namelist
is a comma-separated list of variables and/or arrays
that are to be private to the immediately following
tasks.
namelist
cannot contain dynamic, allocatable,
or automatic arrays.
Example 6-9 task_private
The following Fortran code provides an example of task privatization:
Table 6-4 Form of task_private directive and pragma
Language Form
Fortran C$DIR TASK_PRIVATE(namelist)
C #pragma _CNX task_private(namelist)