Parallel Programming Guide for HP-UX Systems

Parallel synchronization
Synchronizing code
Chapter 8 151
DO I = 2, N
. ! PARALLELIZABLE CODE...
.
.
A(I) = A(I-1) + B(I)
. ! MORE PARALLELIZABLE CODE...
.
.
ENDDO
Assuming that the dependence shown is the only one in the loop, and
that a significant amount of parallel code exists elsewhere in the loop,
the dependence is isolated. The loop is parallelized as shown below:
C$DIR GATE(LCD)
LOCK = ALLOC_GATE(LCD)
.
.
.
LOCK = UNLOCK_GATE(LCD)
C$DIR LOOP_PARALLEL(ORDERED)
DO I = 2, N
. ! PARALLELIZABLE CODE...
.
.
C$DIR ORDERED_SECTION(LCD)
A(I) = A(I-1) + B(I)
C$DIR END_ORDERED_SECTION
. ! MORE PARALLELIZABLE CODE...
.
.
ENDDO
LOCK = FREE_GATE(LCD)