SummaryThe distribute construct specifies that the iterations of one or more loops will be executed
by the initial teams in the context of their implicit tasks. The iterations are distributed across the initial
threads of all initial teams that execute the teams region to which the distribute region
binds.
Syntax
The syntax of the distribute construct is as follows:
The distribute directive places restrictions on the structure of all associated for-loops. Specifically, all
associated for-loops must have canonical loop form (see Section 2.9.1 on page 271).
The syntax of the distribute construct is as follows:
If an enddistribute directive is not specified, an enddistribute directive is assumed at the end
of the do-loops.
The distribute directive places restrictions on the structure of all associated do-loops. Specifically, all
associated do-loops must have canonical loop form (see Section 2.9.1 on page 271).
BindingThe binding thread set for a distribute region is the set of initial threads executing an
enclosing teams region. A distribute region binds to this teams region.
DescriptionThe distribute construct is associated with a loop nest consisting of one or more loops that
follow the directive.
There is no implicit barrier at the end of a distribute construct. To avoid data races the original list
items modified due to lastprivate or linear clauses should not be accessed between the end of
the distribute construct and the end of the teams region to which the distribute
binds.
The collapse clause may be used to specify how many loops are associated with the distribute
construct. The parameter of the collapse clause must be a constant positive integer expression. If no
collapse clause is present or its parameter is 1, the only loop that is associated with the distribute
construct is the one that immediately follows the distribute construct. If a collapse clause is
specified with a parameter value greater than 1 and more than one loop is associated with the distribute
construct, then the iteration of all associated loops are collapsed into one larger iteration space. The
sequential execution of the iterations in all associated loops determines the order of the iterations in the
collapsed iteration space.
A distribute loop has logical iterations numbered 0,1,...,N-1 where N is the number of loop iterations, and
the logical numbering denotes the sequence in which the iterations would be executed if the set of
associated loop(s) were executed sequentially. At the beginning of each logical iteration, the loop iteration
variable of each associated loop has the value that it would have if the set of the associated loop(s) were
executed sequentially.
If more than one loop is associated with the distribute construct then the number of times that any
intervening code between any two associated loops will be executed is unspecified but will be at least once
per iteration of the loop enclosing the intervening code and at most once per iteration of the innermost
loop associated with the construct. If the iteration count of any loop that is associated with the
distribute construct is zero and that loop does not enclose the intervening code, the behavior is
unspecified.
The integer type (or kind, for Fortran) used to compute the iteration count for the collapsed loop is
implementation defined.
If dist_schedule is specified, kind must be static. If specified, iterations are divided into chunks of
size chunk_size, chunks are assigned to the initial teams of the league in a round-robin fashion in the order
of the initial team number. When no chunk_size is specified, the iteration space is divided into chunks that
are approximately equal in size, and at most one chunk is distributed to each initial team of the league. The
size of the chunks is unspecified in this case.
When no dist_schedule clause is specified, the schedule is implementation defined.
Execution Model EventsThe distribute-begin event occurs after an implicit task encounters a
distribute construct but before the task starts to execute the structured block of the distribute
region.
The distribute-end event occurs after an implicit task finishes execution of a distribute region but
before it resumes execution of the enclosing context.
Tool CallbacksA thread dispatches a registered ompt_callback_work callback with
ompt_scope_begin as its endpoint argument and ompt_work_distribute as its wstype argument
for each occurrence of a distribute-begin event in that thread. Similarly, a thread dispatches a registered
ompt_callback_work callback with ompt_scope_end as its endpoint argument and
ompt_work_distribute as its wstype argument for each occurrence of a distribute-end event in that
thread. The callbacks occur in the context of the implicit task. The callbacks have type signature
ompt_callback_work_t.
RestrictionsRestrictions to the distribute construct are as follows:
The
distribute
construct
inherits
the
restrictions
of
the
worksharing-loop
construct.
Each
distribute
region
must
be
encountered
by
the
initial
threads
of
all
initial
teams
in
a
league
or
by
none
at
all.
The
sequence
of
the
distribute
regions
encountered
must
be
the
same
for
every
initial
thread
of
every
initial
team
in
a
league.
The
region
corresponding
to
the
distribute
construct
must
be
strictly
nested
inside
a
teams
region.
A
list
item
may
appear
in
a
firstprivate
or
lastprivate
clause
but
not
both.
The
dist_schedule
clause
must
not
appear
on
the
distribute
directive
if
the
associated
loop(s)
form
a
non-rectangular
loop
nest.
worksharing-loop
construct,
see
Section 2.9.2
on
page 288.
ompt_work_distribute,
see
Section 4.4.4.15
on
page 1292.
ompt_callback_work_t,
see
Section 4.5.2.5
on
page 1329.
2.9.4.2 distributesimd Construct
SummaryThe distributesimd construct specifies a loop that will be distributed across the
master threads of the teams region and executed concurrently using SIMD instructions. The
distributesimd construct is a composite construct.
Syntax
The syntax of the distributesimd construct is as follows:
where clause can be any of the clauses accepted by the distribute or simd directives with identical
meanings and restrictions.
If an enddistributesimd directive is not specified, an enddistributesimd directive is
assumed at the end of the do-loops.
DescriptionThe distributesimd construct will first distribute the iterations of the associated loop(s)
according to the semantics of the distribute construct and any clauses that apply to the distribute
construct. The resulting chunks of iterations will then be converted to a SIMD loop in a manner consistent
with any clauses that apply to the simd construct.
Execution Model Events
This composite construct generates the same events as the distribute construct.
Tool Callbacks
This composite construct dispatches the same callbacks as the distribute construct.
Restrictions
The
restrictions
for
the
distribute
and
simd
constructs
apply.
A
list
item
may
not
appear
in
a
linear
clause
unless
it
is
the
loop
iteration
variable
of
a
loop
that
is
associated
with
the
construct.
The
conditional
modifier
may
not
appear
in
a
lastprivate
clause.
SummaryThe distribute parallel worksharing-loop construct specifies a loop that can be executed in parallel
by multiple threads that are members of multiple teams. The distribute parallel worksharing-loop construct
is a composite construct.
Syntax
The syntax of the distribute parallel worksharing-loop construct is as follows:
where clause can be any of the clauses accepted by the distribute or parallel worksharing-loop
directives with identical meanings and restrictions.
If an enddistributeparalleldo directive is not specified, an enddistributeparalleldo directive is assumed at the end of the do-loops.
DescriptionThe distribute parallel worksharing-loop construct will first distribute the iterations of the
associated loop(s) into chunks according to the semantics of the distribute construct and any clauses
that apply to the distribute construct. Each of these chunks will form a loop. Each resulting loop will
then be distributed across the threads within the teams region to which the distribute
construct binds in a manner consistent with any clauses that apply to the parallel worksharing-loop
construct.
Execution Model Events
This composite construct generates the same events as the distribute and parallel worksharing-loop
constructs.
Tool Callbacks
This composite construct dispatches the same callbacks as the distribute and parallel worksharing-loop
constructs.
Restrictions
The
restrictions
for
the
distribute
and
parallel
worksharing-loop
constructs
apply.
No
ordered
clause
can
be
specified.
No
linear
clause
can
be
specified.
The
conditional
modifier
may
not
appear
in
a
lastprivate
clause.
Cross References
distribute
construct,
see
Section 2.9.4.1
on
page 342.
Parallel
worksharing-loop
construct,
see
Section 2.13.1
on
page 532.
Data
attribute
clauses,
see
Section 2.19.4
on
page 842.
SummaryThe distribute parallel worksharing-loop SIMD construct specifies a loop that can be
executed concurrently using SIMD instructions in parallel by multiple threads that are members
of multiple teams. The distribute parallel worksharing-loop SIMD construct is a composite
construct.
Syntax
The syntax of the distribute parallel worksharing-loop SIMD construct is as follows:
where clause can be any of the clauses accepted by the distribute or parallel worksharing-loop SIMD
directives with identical meanings and restrictions.
The syntax of the distribute parallel worksharing-loop SIMD construct is as follows:
where clause can be any of the clauses accepted by the distribute or parallel worksharing-loop SIMD
directives with identical meanings and restrictions.
If an enddistributeparalleldosimd directive is not specified, an enddistributeparalleldosimd directive is assumed at the end of the do-loops.
DescriptionThe distribute parallel worksharing-loop SIMD construct will first distribute the iterations of
the associated loop(s) according to the semantics of the distribute construct and any clauses that apply
to the distribute construct. The resulting loops will then be distributed across the threads contained
within the teams region to which the distribute construct binds in a manner consistent with any
clauses that apply to the parallel worksharing-loop construct. The resulting chunks of iterations will then
be converted to a SIMD loop in a manner consistent with any clauses that apply to the simd
construct.
Execution Model Events
This composite construct generates the same events as the distribute and parallel worksharing-loop
SIMD constructs.
Tool Callbacks
This composite construct dispatches the same callbacks as the distribute and parallel worksharing-loop
SIMD constructs.
Restrictions
The
restrictions
for
the
distribute
and
parallel
worksharing-loop
SIMD
constructs
apply.
No
ordered
clause
can
be
specified.
A
list
item
may
not
appear
in
a
linear
clause
unless
it
is
the
loop
iteration
variable
of
a
loop
that
is
associated
with
the
construct.
The
conditional
modifier
may
not
appear
in
a
lastprivate
clause.
Cross References
distribute
construct,
see
Section 2.9.4.1
on
page 342.
Parallel
worksharing-loop
SIMD
construct,
see
Section 2.13.5
on
page 543.
Data
attribute
clauses,
see
Section 2.19.4
on
page 842.