Technical data
Cray Standard C/C++ Reference Manual
.
.
#pragma _CRI endparallel
3.8.7 guard and endguard Directives (UNICOS Systems)
Scope: Local
The guard and endguard directive pair delimit a guarded region and provide
the necessary synchronization to protect (or guard) the code inside the guarded
region. A
guarded region is a code block that is to be executed by only one
processor at a time, although all processors in the parallel region execute it.
The format of the guard and endguard directives is as follows:
#pragma _CRI guard [exp]
#pragma _CRI endguard [exp]
Unnumbered guards do not use the optional parameter exp on the guard
and endguard directives. Only one processor is allowed to execute in an
unnumbered guarded region at a time. If a processor is executing in an
unnumbered guarded region, and a second processor wants to enter an
unnumbered guarded region, the second processor must wait until the first
processor exits the region.
Numbered guards are indicated by the use of the optional parameter exp. The
expression exp must be an integral expression. Only the low-order 6 bits of exp
are used, thereby allowing up to 64 distinct numbered guards (0 through 63). For
optimal performance, exp should be an integer constant; the general expression
capability is provided only for the unusual case that the guarded region number
must be passed to a lower-level function.
The following example illustrates the use of the guard and endguard directives:
#pragma _CRI guard /* protect the update of sum and big */
sum = sum + xsum;
big = max(xbig, big);
#pragma _CRI endguard
74 S–2179–36










