OpenMP-Examples/synchronization/barrier_regions.tex
2024-04-16 08:59:23 -07:00

26 lines
1.1 KiB
TeX

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