Technical data

#pragma Directives [3]
3.8.8 taskprivate Directive (Cray Standard C Compiler)
The taskprivate directive specifies the task private storage class for variables.
The format of this directive is as follows (the comma-separated list of variables
can be enclosed in parentheses):
#pragma _CRI taskprivate variable,...
Variables that are given a task private storage class are placed in storage so that
each task has a separate copy of the variables; all functions within a task can
access the same copy of the task private variable, but no task can access any task
private variables belonging to another task.
A primary use for task private variables is efficient porting of macrotasked
programs from a shared-memory system (that is, a system, such as VAX, on
which independently executing programs can access the other programs
memory). On UNICOS and UNICOS/mk systems, independently executing
programs cannot access memory belonging to other programs.
This directive can appear in both global and local scopes and applies only to the
following types of variables:
Global scope variables, in which case the directive must appear at global
scope.
Local scope variables with static storage class, in which case the directive
must appear within the same scope as the variable declaration.
When a variable is designated as task private, subsequent declarations of that
variable in the same source file inherit the task private storage class.
The following example, in which each task gets a private copy of x initialized to
10, illustrates the use of the taskprivate directive
main() {
static int x = 10;
#pragma _CRI taskprivate x
...
}
The taskprivate directive takes precedence over the -h common and the
-h taskcommon command line options.
The following restrictions apply to the taskprivate variable:
S217936 75