| Name: task | Association: block |
| Category: executable | Properties: parallelism-generating, thread-limiting, task-generating |
|
|
Clauses
affinity, allocate, default, depend, detach, final, firstprivate, if, in_reduction, mergeable, priority, private, shared, untied| Properties: exclusive | |
|
|
Binding
The binding thread set of the task region is the current team. A task region binds to the innermost enclosing parallel region.Semantics
When a thread encounters a task construct, an explicit task is generated from the code for the associated structured block. The data environment of the task is created according to the data-sharing attribute clauses on the task construct, per-data environment ICVs, and any defaults that apply. The data environment of the task is destroyed when the execution code of the associated structured block is completed.The encountering thread may immediately execute the task, or defer its execution. In the latter case, any thread in the team may be assigned the task. Completion of the task can be guaranteed using task synchronization constructs and clauses. If a task construct is encountered during execution of an outer task, the generated task region that corresponds to this construct is not a part of the outer task region unless the generated task is an included task.
A detachable task is completed when the execution of its associated structured block is completed and the allow-completion event is fulfilled. If no detach clause is present on a task construct, the generated task is completed when the execution of its associated structured block is completed.
A thread that encounters a task scheduling point within the task region may temporarily suspend the task region.
The task construct includes a task scheduling point in the task region of its generating task, immediately following the generation of the explicit task. Each explicit task region includes a task scheduling point at the end of its associated structured block.
When an if clause is present on a task construct and the if clause expression evaluates to false, an undeferred task is generated, and the encountering thread must suspend the current task region, for which execution cannot be resumed until execution of the structured block that is associated with the generated task is completed. The use of a variable in an if clause expression of a task construct causes an implicit reference to the variable in all enclosing constructs. The if clause expression is evaluated in the context outside of the task construct.
Execution Model Events
The task-create event occurs when a thread encounters a construct that causes a new task to be created. The event occurs after the task is initialized but before it begins execution or is deferred.Tool Callbacks
A thread dispatches a registered ompt_callback_task_create callback for each occurrence of a task-create event in the context of the encountering task. This callback has the type signature ompt_callback_task_create_t and the flags argument indicates the task types shown in 12.1.tableompt_callback_task_create Callback Flags Evaluation
| Operation | Evaluates to true |
| (flags & ompt_task_explicit) | Always in the dispatched callback |
| (flags & ompt_task_undeferred) | If the task is an undeferred task |
| (flags & ompt_task_final) | If the task is a final task |
| (flags & ompt_task_untied) | If the task is an untied task |
| (flags & ompt_task_mergeable) | If the task is a mergeable task |
| (flags & ompt_task_merged) | If the task is a merged task |
Cross References