Summary
The ordered construct either specifies a structured block in a worksharing-loop, simd, or
worksharing-loop SIMD region that will be executed in the order of the loop iterations, or it is a stand-alone
directive that specifies cross-iteration dependences in a doacross loop nest. The ordered construct
sequentializes and orders the execution of ordered regions while allowing code outside the region to run
in parallel.
Syntax
The syntax of the ordered construct is as follows:
If the depend clause is specified, the ordered construct is a stand-alone directive.
Binding
The binding thread set for an ordered region is the current team. An ordered region binds to the
innermost enclosing simd or worksharing-loop SIMD region if the simd clause is present, and otherwise
it binds to the innermost enclosing worksharing-loop region. ordered regions that bind to different
regions execute independently of each other.
Description
If no clause is specified, the ordered construct behaves as if the threads clause had been specified. If
the threads clause is specified, the threads in the team that is executing the worksharing-loop region
execute ordered regions sequentially in the order of the loop iterations. If any depend clauses are
specified then those clauses specify the order in which the threads in the team execute ordered regions. If
the simd clause is specified, the ordered regions encountered by any thread will execute one at a time in
the order of the loop iterations.
When the thread that is executing the first iteration of the loop encounters an ordered construct, it can
enter the ordered region without waiting. When a thread that is executing any subsequent iteration
encounters an ordered construct without a depend clause, it waits at the beginning of the
ordered region until execution of all ordered regions that belong to all previous iterations has
completed. When a thread that is executing any subsequent iteration encounters an ordered
construct with one or more depend(sink:vec) clauses, it waits until its dependences on all
valid iterations specified by the depend clauses are satisfied before it completes execution
of the ordered region. A specific dependence is satisfied when a thread that is executing
the corresponding iteration encounters an ordered construct with a depend(source)
clause.
Execution Model Events
The ordered-acquiring event occurs in the task that encounters the ordered construct on entry to the
ordered region before it initiates synchronization for the region.
The ordered-acquired event occurs in the task that encounters the ordered construct after it enters the
region, but before it executes the structured block of the ordered region.
The ordered-released event occurs in the task that encounters the ordered construct after it completes any
synchronization on exit from the ordered region.
The doacross-sink event occurs in the task that encounters an ordered construct for each
depend(sink:vec) clause after the dependence is fulfilled.
The doacross-source event occurs in the task that encounters an ordered construct with a
depend(source:vec) clause before signaling the dependence to be fulfilled.
Tool Callbacks
A thread dispatches a registered ompt_callback_mutex_acquire callback for each
occurrence of an ordered-acquiring event in that thread. This callback has the type signature
ompt_callback_mutex_acquire_t.
A thread dispatches a registered ompt_callback_mutex_acquired callback for each
occurrence of an ordered-acquired event in that thread. This callback has the type signature
ompt_callback_mutex_t.
A thread dispatches a registered ompt_callback_mutex_released callback with
ompt_mutex_ordered as the kind argument if practical, although a less specific kind may be
used, for each occurrence of an ordered-released event in that thread. This callback has the type
signature ompt_callback_mutex_t and occurs in the task that encounters the atomic
construct.
A thread dispatches a registered ompt_callback_dependences callback with all vector entries listed
as ompt_dependence_type_sink in the deps argument for each occurrence of a doacross-sink event
in that thread. A thread dispatches a registered ompt_callback_dependences callback with all
vector entries listed as ompt_dependence_type_source in the deps argument for each
occurrence of a doacross-source event in that thread. These callbacks have the type signature
ompt_callback_dependences_t.
Restrictions
Restrictions to the ordered construct are as follows:
At
most
one
threads
clause
can
appear
on
an
ordered
construct.
At
most
one
simd
clause
can
appear
on
an
ordered
construct.
At
most
one
depend(source)
clause
can
appear
on
an
ordered
construct.
The
construct
that
corresponds
to
the
binding
region
of
an
ordered
region
must
not
specify
a
reduction
clause
with
the
inscan
modifier.
Either
depend(sink:vec)
clauses
or
depend(source)
clauses
may
appear
on
an
ordered
construct,
but
not
both.
The
worksharing-loop
or
worksharing-loop
SIMD
region
to
which
an
ordered
region
corresponding
to
an
ordered
construct
without
a
depend
clause
binds
must
have
an
ordered
clause
without
the
parameter
specified
on
the
corresponding
worksharing-loop
or
worksharing-loop
SIMD
directive.
The
worksharing-loop
region
to
which
an
ordered
region
that
corresponds
to
an
ordered
construct
with
any
depend
clauses
binds
must
have
an
ordered
clause
with
the
parameter
specified
on
the
corresponding
worksharing-loop
directive.
An
ordered
construct
with
the
depend
clause
specified
must
be
closely
nested
inside
a
worksharing-loop
(or
parallel
worksharing-loop)
construct.
An
ordered
region
that
corresponds
to
an
ordered
construct
without
the
simd
clause
specified
must
be
closely
nested
inside
a
worksharing-loop
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
with
the
simd
clause
specified
must
be
closely
nested
inside
a
simd
or
worksharing-loop
SIMD
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
with
both
the
simd
and
threads
clauses
must
be
closely
nested
inside
a
worksharing-loop
SIMD
region
or
must
be
closely
nested
inside
a
worksharing-loop
and
simd
region.
During
execution
of
an
iteration
of
a
worksharing-loop
or
a
loop
nest
within
a
worksharing-loop,
simd,
or
worksharing-loop
SIMD
region,
a
thread
must
not
execute
more
than
one
ordered
region
that
corresponds
to
an
ordered
construct
without
a
depend
clause.
A
throw
executed
inside
a
ordered
region
must
cause
execution
to
resume
within
the
same
ordered
region,
and
the
same
thread
that
threw
the
exception
must
catch
it.