Summary
A loop construct specifies that the logical iterations of the associated loops may execute concurrently and
permits the encountering threads to execute the loop accordingly.
If an endloop directive is not specified, an endloop directive is assumed at the end of the
do-loops.
Binding
If the bind clause is present on the construct, the binding region is determined by binding. Specifically, if
binding is teams and an innermost enclosing teams region exists then the binding region is that
teams region; if binding is parallel then the binding region is the innermost enclosing
parallel region, which may be an implicit parallel region; and if binding is thread then the
binding region is not defined. If the bind clause is not present on the construct and the loop
construct is closely nested inside a teams or parallel construct, the binding region is the
corresponding teams or parallel region. If none of those conditions hold, the binding region is not
defined.
If the binding region is a teams region, then the binding thread set is the set of initial threads that are
executing that region. If the binding region is a parallel region, then the binding thread set is the team of
threads that are executing that region. If the binding region is not defined, then the binding thread set is the
encountering thread.
Description
The loop construct is associated with a loop nest that consists of one or more loops that follow the
directive. The directive asserts that the iterations may execute in any order, including concurrently.
The collapse clause may be used to specify how many loops are associated with the loop construct.
The parameter of the collapse clause must be a constant positive integer expression. If the collapse
clause is omitted, the behavior is as if a collapse clause with a parameter value of one was specified.
The collapse clause specifies the number of loops that are collapsed into a logical iteration
space.
At the beginning of each logical iteration, the loop iteration variable or the variable declared by range-decl
of each associated loop has the value that it would have if the set of the associated loops was executed
sequentially.
Each logical iteration is executed once per instance of the loop region that is encountered by the binding
thread set.
If an order clause is present then the semantics are as described in Section 2.11.3. If the order clause is
not present, the behavior is as if an order clause that specifies concurrent appeared on the
construct.
The set of threads that may execute the iterations of the loop region is the binding thread set. Each iteration
is executed by one thread from this set.
If the loop region binds to a teams region, the threads in the binding thread set may continue execution
after the loop region without waiting for all logical iterations of the associated loops to complete. The
iterations are guaranteed to complete before the end of the teams region.
If the loop region does not bind to a teams region, all logical iterations of the associated loops must
complete before the encountering threads continue execution after the loop region.
For the purpose of determining its consistency with other schedules (see Section 2.11.2), the schedule is
defined by the implicit order clause.
The schedule is reproducible if the schedule specified through the implicit order clause is
reproducible.
Restrictions
Restrictions to the loop construct are as follows:
At
most
one
collapse
clause
can
appear
on
a
loop
directive.
A
list
item
may
not
appear
in
a
lastprivate
clause
unless
it
is
the
loop
iteration
variable
of
a
loop
that
is
associated
with
the
construct.
If
a
loop
construct
is
not
nested
inside
another
OpenMP
construct
and
it
appears
in
a
procedure,
the
bind
clause
must
be
present.
If
a
loop
region
binds
to
a
teams
or
parallel
region,
it
must
be
encountered
by
all
threads
in
the
binding
thread
set
or
by
none
of
them.
At
most
one
bind
clause
can
appear
on
a
loop
directive.
If
the
bind
clause
is
present
on
the
loop
construct
and
binding
is
teams
then
the
corresponding
loop
region
must
be
strictly
nested
inside
a
teams
region.
If
the
bind
clause,
with
teams
specified
as
binding,
is
present
on
the
loop
construct
and
the
corresponding
loop
region
executes
on
a
non-host
device
then
the
behavior
of
a
reduction
clause
that
appears
on
the
construct
is
unspecified
if
the
construct
is
not
nested
inside
a
teams
construct.
If
the
bind
clause
is
present
on
the
loop
construct
and
binding
is
parallel
then
the
behavior
is
unspecified
if
the
corresponding
loop
region
is
closely
nested
inside
a
simd
region.