Tasks
Definition:
Task construct defines a section of code.
Inside a parallel region, a thread encountering a task construct will package up the task for execution.
Some thread in the parallel region will execute the task at some point in the future.
Data Sharing:
The default for tasks is usually
FIRSTPRIVATE
, because the task may not be executed until later (and variables may have gone out of scope).Variables that are shared in all constructs starting from the innermost enclosing parallel construct are shared.
Getting data attribute scoping right can be quite tricky, using
default(none)
is a good idea.
Task complete time:
At thread barriers, whether explicit or implicit
at the end of current parallel region, there is an implicit barrier to all tasks
At
taskwait
directiveWait until all tasks defined in the current task have completed.
#pragma omp taskwait
Note: applies only to tasks generated in the current task, not to "descendants".
Task switching:
Certain constructs have task scheduling points at defined locations within them
When a thread encounters a task scheduling point, it is allowed to suspend the current task and execute another (called task switching)
It can then return to the original task and resume.
Example of
taskyield
from SC15
Reference
Last updated