HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

11.5  Worksharing-Loop Constructs

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:

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

TABLE 11.1: ompt_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:

Cross References