Binding
The binding thread set for a worksharing-loop region is the current team. A worksharing-loop region binds to the innermost enclosing parallel region. Only those threads participate in execution of the loop iterations and the implied barrier of the worksharing-loop region when that barrier is not eliminated by a nowait clause.Semantics
The worksharing-loop construct is a worksharing construct that specifies that the iterations of one or more associated loops will be executed in parallel by threads in the team in the context of their implicit tasks. The iterations are distributed across threads that already exist in the team that is executing the parallel region to which the worksharing-loop region binds. Each thread executes its assigned chunks in the context of its implicit task. The iterations of a given chunk are executed in sequential order.If specified, the schedule clause determines the schedule of the logical iterations associated with the construct. That is, it determines the division of iterations into chunks and how those chunks are assigned to the threads. If the schedule clause is not specified then the schedule is implementation defined.
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.
The schedule is reproducible if one of the following conditions is true:
The order clause is specified with the reproducible order-modifier; or
The schedule clause is specified with static as the kind argument but not the simd ordering-modifier and the order clause is not specified with the unconstrained order-modifier.
Programs can only depend on which thread executes a particular iteration if the schedule is reproducible. Schedule reproducibility also determines the consistency with the execution of constructs with the same schedule.
Execution Model Events
The ws-loop-begin event occurs after an implicit task encounters a worksharing-loop construct but before the task starts execution of the structured block of the worksharing-loop region.The ws-loop-end event occurs after a worksharing-loop region finishes execution but before resuming execution of the encountering task.
The ws-loop-iteration-begin event occurs at the beginning of each iteration of a worksharing-loop region. The ws-loop-chunk-begin event occurs for each scheduled chunk of a worksharing-loop region before the implicit task executes any of the associated iterations.
Tool Callbacks
A thread dispatches a registered ompt_callback_work callback with ompt_scope_begin as its endpoint argument for each occurrence of a ws-loop-begin event in that thread. Similarly, a thread dispatches a registered ompt_callback_work callback with ompt_scope_end as its endpoint argument for each occurrence of a ws-loop-end event in that thread. The callbacks occur in the context of the implicit task. The callbacks have type signature ompt_callback_work_t and the work_type argument indicates the schedule as shown in 11.1.A thread dispatches a registered ompt_callback_dispatch callback for each occurrence of a ws-loop-iteration-begin or ws-loop-chunk-begin event in that thread. The callback occurs in the context of the implicit task. The callback has type signature ompt_callback_dispatch_t.
tableompt_callback_work Callback Work Types for Worksharing-Loop
Value of work_type | If determined schedule is |
ompt_work_loop | unknown at runtime |
ompt_work_loop_static | static |
ompt_work_loop_dynamic | dynamic |
ompt_work_loop_guided | guided |
ompt_work_loop_other | implementation specific |
Restrictions
Restrictions to the worksharing-loop construct are as follows:The logical iteration space of the loops associated with the worksharing-loop construct must be the same for all threads in the team.
The value of the run-sched-var ICV must be the same for all threads in the team.
Cross References
Consistent Loop Schedules, see Section 4.4.5
OMP_SCHEDULE, see Section 21.2.1
ompt_callback_work_t, see Section 19.5.2.5
ompt_scope_endpoint_t, see Section 19.4.4.11
ompt_work_t, see Section 19.4.4.16
do directive, see Section 11.5.2
for directive, see Section 11.5.1
nowait clause, see Section 15.6
order clause, see Section 10.3
schedule clause, see Section 11.5.3