Parallel Programming Guide for HP-UX Systems

Parallel synchronization
Synchronization tools
Chapter 8142
The form of sync_routine is shown in Table 8-7.
where
routinelist
is a comma-separated list of synchronization routines.
Example 8-1 sync_routine
sync_routine is effective only for the listed routines that lexically follow
it in the same file where it appears. The following Fortran code example
features the sync_routine directive:
INTEGER MY_LOCK, MY_UNLOCK
C$DIR GATE(LOCK)
C$DIR SYNC_ROUTINE(MY_LOCK, MY_UNLOCK)
.
.
.
LCK = ALLOC_GATE(LOCK)
C$DIR LOOP_PARALLEL
DO I = 1, N
LCK = MY_LOCK(LOCK)
.
.
.
SUM = SUM + A(I)
LCK = MY_UNLOCK(LOCK)
ENDDO
.
.
.
INTEGER FUNCTION MY_LOCK(LOCK)
C$DIR GATE(LOCK)
LCK = LOCK_GATE(LOCK)
MY_LOCK = LCK
RETURN
END
INTEGER FUNCTION MY_UNLOCK(LOCK)
C$DIR GATE(LOCK)
LCK = UNLOCK_GATE(LOCK)
Table 8-7 Form of sync_routine directive and pragma
Language Form
Fortran C$DIR SYNC_ROUTINE (routinelist)
C #pragma CNX sync_routine (routinelist)