mirror of
https://github.com/OpenMP/Examples.git
synced 2025-04-16 11:18:06 +01:00
23 lines
949 B
TeX
23 lines
949 B
TeX
\pagebreak
|
|
\section{\code{taskgroup} Construct}
|
|
\label{sec:taskgroup}
|
|
\index{constructs!taskgroup@\code{taskgroup}}
|
|
\index{taskgroup construct@\code{taskgroup} construct}
|
|
|
|
In this example, tasks are grouped and synchronized using the \code{taskgroup}
|
|
construct.
|
|
|
|
Initially, one task (the task executing the \code{start\_background\_work()}
|
|
call) is created in the \code{parallel} region, and later a parallel tree traversal
|
|
is started (the task executing the root of the recursive \code{compute\_tree()}
|
|
calls). While synchronizing tasks at the end of each tree traversal, using the
|
|
\code{taskgroup} construct ensures that the formerly started background task
|
|
does not participate in the synchronization and is left free to execute in parallel.
|
|
This is opposed to the behavior of the \code{taskwait} construct, which would
|
|
include the background tasks in the synchronization.
|
|
|
|
\cexample[4.0]{taskgroup}{1}
|
|
|
|
\ffreeexample[4.0]{taskgroup}{1}
|
|
|