5.6
62.4
123.6

Tasking allows the parallelization of applications where work units are generated dynamically, as in recursive structures or while loops.

#pragma omp task[clause[[,]clause]...] structured-block

The task directive defines the code associated with the task and its data
generated. The task may be executed immediately or at a later time. If
task execution is delayed, then the task is placed in a conceptual
pool of sleeping tasks that is associated with the current parallel region. The threads in the current teams will take tasks out of the pool and
execute them until the pool is empty. A thread that executes a task
might be different than the one that originally encountered it.

The code associated with the task construct will be executed only
once. A task is named to be tied, if it is executed by the same thread
from beginning to end. A task is untied if the code can be executed by
parts of the code. By default, tasks are tied.

We also want to mention that there are several task scheduling points where a task can be put from living into sleeping and back from sleeping to a living state:

• In the generating task: after the task generates an explicit task, it can be put into a sleeping state.
• In the generated task: after the last instruction of the task region.
• In implicit and explicit barriers.
• In taskwait.

Completion of a task can be guaranteed using task synchronization constructs such as taskwait directive. The taskwait construct specifies a wait on the completion of child tasks of the current task. The taskwait construct is a stand-alone directive.

#pragma omp taskwait [clause[ [,] clause] ... ]