Technical data
Analyzing Data Dependencies for Multiprocessing
83
Subroutines,”) cannot safely be included in a parallel loop. In particular,
rand is not safe for multiprocessing. For user-written routines, it is the
responsibility of the user to ensure that the routines can be correctly
multiprocessed.
Caution: Routines called within a parallel loop cannot be compiled with the
–static flag.
Example 6: Rewritable Data Dependence
INDX = 0
DO I = 1, N
INDX = INDX + I
A(I) = B(I) + C(INDX)
END DO
Here, the value of INDX survives the loop iteration and is carried into the
next iteration. This loop cannot be parallelized as it is written. Making INDX
a LOCAL variable does not work; you need the value of INDX computed in
the previous iteration. It is possible to rewrite this loop to make it parallel
(see Example 1 in “Breaking Data Dependencies” on page 85).
Example 7: Exit Branch
DO I = 1, N
IF (A(I) .LT. EPSILON) GOTO 320
A(I) = A(I) * B(I)
END DO
320 CONTINUE
This loop contains an exit branch; that is, under certain conditions the flow
of control suddenly exits the loop. The Fortran compiler cannot parallelize
loops containing exit branches.
Example 8: Complicated Independence
DO I = K+1, 2*K
W(I) = W(I) + B(I,K) * W(I-K)
END DO










