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

12.6  taskloop Construct

Name: taskloop

Association: loop

Category: executable

Properties: parallelism-generating, task-generating

Clauses

allocate, collapse, default, final, firstprivate, grainsize, if, in_reduction, lastprivate, mergeable, nogroup, num_tasks, priority, private, reduction, shared, untied

Clause set

synchronization-clause

Properties: exclusive

Members: nogroup, reduction

Clause set

granularity-clause

Properties: exclusive

Members: grainsize, num_tasks

Binding

The binding thread set of the taskloop region is the current team. A taskloop region binds to the innermost enclosing parallel region.

Semantics

When a thread encounters a taskloop construct, the construct partitions the iterations of the associated loops into chunks, each of which is assigned to an explicit task for parallel execution. The iteration count for each associated loop is computed before entry to the outermost loop. The data environment of each generated task is created according to the data-sharing attribute clauses on the taskloop construct, per-data environment ICVs, and any defaults that apply. The order of the creation of the loop tasks is unspecified. Programs that rely on any execution order of the logical iterations are non-conforming.

If the nogroup clause is not present, the taskloop construct executes as if it was enclosed in a taskgroup construct with no statements or directives outside of the taskloop construct. Thus, the taskloop construct creates an implicit taskgroup region. If the nogroup clause is present, no implicit taskgroup region is created.

If a reduction clause is present, the behavior is as if a task_reduction clause with the same reduction operator and list items was applied to the implicit taskgroup construct that encloses the taskloop construct. The taskloop construct executes as if each generated task was defined by a task construct on which an in_reduction clause with the same reduction operator and list items is present. Thus, the generated tasks are participants of the reduction defined by the task_reduction clause that was applied to the implicit taskgroup construct.

If an in_reduction clause is present, the behavior is as if each generated task was defined by a task construct on which an in_reduction clause with the same reduction operator and list items is present. Thus, the generated tasks are participants of a reduction previously defined by a reduction scoping clause.

If no clause from the granularity-clause set is present, the number of loop tasks generated and the number of logical iterations assigned to these tasks 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.

When an if clause is present and the if clause expression evaluates to false, undeferred tasks are generated. The use of a variable in an if clause expression causes an implicit reference to the variable in all enclosing constructs.

For firstprivate variables of class type, the number of invocations of copy constructors that perform the initialization is implementation defined.
When storage is shared by a taskloop region, the programmer must ensure, by adding proper synchronization, that the storage does not reach the end of its lifetime before the taskloop region and its descendent tasks complete their execution.

Execution Model Events

The taskloop-begin event occurs upon entering the taskloop region. A taskloop-begin will precede any task-create events for the generated tasks. The taskloop-end event occurs upon completion of the taskloop region.

Events for an implicit taskgroup region that surrounds the taskloop region are the same as for the taskgroup construct.

The taskloop-iteration-begin event occurs at the beginning of each iteration of a taskloop region before an explicit task executes the iteration. The taskloop-chunk-begin event occurs before an explicit task executes any of its associated iterations in a taskloop region.

Tool Callbacks

A thread dispatches a registered ompt_callback_work callback for each occurrence of a taskloop-begin and taskloop-end event in that thread. The callback occurs in the context of the encountering task. The callback has type signature ompt_callback_work_t. The callback receives ompt_scope_begin or ompt_scope_end as its endpoint argument, as appropriate, and ompt_work_taskloop as its work_type argument.

A thread dispatches a registered ompt_callback_dispatch callback for each occurrence of a taskloop-iteration-begin or taskloop-chunk-begin event in that thread.

The callback binds to the explicit task executing the iterations. The callback has type signature ompt_callback_dispatch_t.

Restrictions

Restrictions to the taskloop construct are as follows:

Cross References