safeptr (nosafeptr). The Portland Group PGI Compiler
Διαφήμιση
Διαφήμιση
Chapter 17. Directives and Pragmas Reference
v = t
If a scalar assigned within a loop is used outside the loop, we normally save the last value of the scalar.
Essentially the value of the scalar on the "last iteration" is saved, in this case when i=N
.
If the loop is parallelized and the scalar is not assigned on every iteration, it may be difficult to determine on what iteration t
is last assigned, without resorting to costly critical sections. Analysis allows the compiler to determine if a scalar is assigned on every iteration, thus the loop is safe to parallelize if the scalar is used later.
An example loop is:
do i = 1, N
if( x(i) > 0.0 ) then
t = 2.0
else
t = 3.0
endif
y(i) = ...t...
enddo
v = t where t
is assigned on every iteration of the loop. However, there are cases where a scalar may be privatizable.
If it is used after the loop, it is unsafe to parallelize. Examine this loop: do i = 1,N
if( x(i) > 0.0 ) then
t = x(i)
...
...
y(i) = ...t..
endif enddo v = t where each use of t
within the loop is reached by a definition from the same iteration. Here t
is privatizable, but the use of t
outside the loop may yield incorrect results since the compiler may not be able to detect on which iteration of the parallelized loop t
is assigned last.
The compiler detects the above cases. Where a scalar is used after the loop, but is not defined on every iteration of the loop, parallelization will not occur.
If you know that the scalar is assigned on the last iteration of the loop, making it safe to parallelize the loop, a directive or pragma is available to let the compiler know the loop is safe to parallelize. Use the following
C pragma to tell the compiler that for a given loop the last value computed for all scalars make it safe to parallelize the loop: cpgi$l safe_lastval
#pragma loop safe_lastval
In addition, a command-line option,
-Msafe_lastval
, provides this information for all loops within the routines being compiled, essentially providing global scope.
safeptr (nosafeptr)
The directive or pragma safeptr directs the compiler to treat pointer variables of the indicated storage class as safe. The pragma nosafeptr directs the compiler to treat pointer variables of the indicated storage class as unsafe. This pragma alters the effects of the –Msafeptr command-line option.
269
Λήψη
Διαφήμιση