Parallel Programming Guide for HP-UX Systems
Parallel synchronization
Synchronization tools
Chapter 8136
Synchronization tools
The compiler cannot automatically parallelize loops containing complex
dependences. However, a rich set of directives, pragmas, and data types
is available to help you manually parallelize such loops by synchronizing
and ordering access to the code containing the dependence.
These directives can also be used to synchronize dependences in parallel
tasks. They allow you to efficiently exploit parallelism in structures that
would otherwise be unparallelizable.
Using gates and barriers
Gates allow you to restrict execution of a block of code to a single thread.
They are allocated, locked, unlocked, and deallocated using the functions
described in “Synchronization functions” on page 137. They can also be
used with the ordered or critical section directives, which automate the
locking and unlocking functions.
Barriers block further execution until all executing threads reach the
barrier and then thread 0 can proceed past the barrier.
Gates and barriers use dynamically allocatable variables, declared using
compiler directives in Fortran and using data declarations in C and C++.
They may be initialized and referenced only by passing them as
arguments to the functions discussed in the following sections.
The forms of these variable declarations are shown in Table 8-1.
Table 8-1 Forms of gate and barriers variable declarations
Language Form
Fortran C$DIR GATE(namelist)
C$DIR BARRIER(namelist)
C/C++ gate_t namelist;
barrier_t namelist;