OpenMP-Examples/Examples_barrier_regions.tex

25 lines
995 B
TeX

\pagebreak
\section{Binding of \code{barrier} Regions}
\label{sec:barrier_regions}
The binding rules call for a \code{barrier} region to bind to the closest enclosing
\code{parallel} region.
In the following example, the call from the main program to \plc{sub2} is conforming
because the \code{barrier} region (in \plc{sub3}) binds to the \code{parallel}
region in \plc{sub2}. The call from the main program to \plc{sub1} is conforming
because the \code{barrier} region binds to the \code{parallel} region in subroutine
\plc{sub2}.
The call from the main program to \plc{sub3} is conforming because the \code{barrier}
region binds to the implicit inactive \code{parallel} region enclosing the sequential
part. Also note that the \code{barrier} region in \plc{sub3} when called from
\plc{sub2} only synchronizes the team of threads in the enclosing \code{parallel}
region and not all the threads created in \plc{sub1}.
\cexample{barrier_regions}{1}
\fexample{barrier_regions}{1}