Parallel Programming Guide for HP-UX Systems

Parallel synchronization
Synchronization tools
Chapter 8 147
Ordered sections
Ordered sections allow you to synchronize dependences that must
execute in iteration order. The ordered_section and
end_ordered_section directives and pragmas are used to specify
critical sections within manually defined, ordered loop_parallel loops
only.
The forms of these directives and pragmas are shown in Table 8-9.
where
gate
is a required gate variable that must be allocated and,
if necessary, unlocked prior to invocation of the parallel
loop containing the ordered section.
gate
must be
appropriately declared as described in the “Using gates
and barriers” section of this chapter.
Ordered sections must be entered through ordered_section and exited
through end_ordered_section. They cannot contain branches to
outside the section. Ordered sections are subject to the same control flow
rules as critical sections.
NOTE As with critical sections, ordered sections should be used
with care, as they add synchronization overhead to your
program. They should only be used when the amount of
parallel code is significantly larger than the amount of
code containing the dependence.
Table 8-9 Forms of ordered_section, end_ordered_section directives
and pragmas
Language Form
Fortran C$DIR ORDERED_SECTION(gate)
...
C$DIR END_ORDERED_SECTION
C #pragma _CNX
ordered_section(gate) ...#pragma _CNX
end_ordered_section