Parallel Programming Guide for HP-UX Systems

Troubleshooting
Misused directives and pragmas
Chapter 9188
DO I = 1, 1025
IN(I) = I
ENDDO
CALL CALC(IN)
CALL OUTPUT(A)
END
SUBROUTINE CALC(IN)
INTEGER IN(1025)
REAL A(1025)
COMMON /DATA/ A
DO I = 1, 1025
A(I) = A(IN(I))
ENDDO
RETURN
END
Because you know that IN(I) = I, you can use the
NO_LOOP_DEPENDENCE directive, as shown below. This directive allows
the compiler to ignore the apparent dependence and parallelize the loop,
when compiling with +O3 +Oparallel.
SUBROUTINE CALC(IN)
INTEGER IN(1025)
REAL A(1025)
COMMON /DATA/ A
C$DIR NO_LOOP_DEPENDENCE(A)
DO I = 1, 1025
A(I) = A(IN(I))
ENDDO
RETURN
END
Reductions
Reductions are a special class of dependence that the compiler can
parallelize. An apparent LCD can prevent the compiler from
parallelizing a loop containing a reduction.
The loop in the following Fortran example is not parallelized because of
an apparent dependence between the references to A(I) on line 6 and the
assignment to A(JA(J)) on line 7. The compiler does not realize that the