OpenMP-Examples/program_control/nesting_restrict.tex
2024-04-16 08:59:23 -07:00

55 lines
1.5 KiB
TeX

%\pagebreak
\section{Restrictions on Nesting of Regions}
\label{sec:nesting_restrict}
\index{region nesting rules}
The examples in this section illustrate the region nesting rules.
The following example is non-conforming because the inner and outer loop regions
are closely nested:
\cexample{nesting_restrict}{1}
\fexample{nesting_restrict}{1}
The following orphaned version of the preceding example is also non-conforming:
\cexample{nesting_restrict}{2}
\fexample{nesting_restrict}{2}
The following example is non-conforming because the loop and \kcode{single} regions
are closely nested:
\cexample{nesting_restrict}{3}
\pagebreak
\fexample{nesting_restrict}{3}
The following example is non-conforming because a \kcode{barrier} region cannot
be closely nested inside a loop region:
\cexample{nesting_restrict}{4}
\fexample{nesting_restrict}{4}
The following example is non-conforming because the \kcode{barrier} region cannot
be closely nested inside the \kcode{critical} region. If this were permitted,
it would result in deadlock due to the fact that only one thread at a time can
enter the \kcode{critical} region:
\cexample{nesting_restrict}{5}
\fexample{nesting_restrict}{5}
The following example is non-conforming because the \kcode{barrier} region cannot
be closely nested inside the \kcode{single} region. If this were permitted, it
would result in deadlock due to the fact that only one thread executes the \kcode{single}
region:
\cexample{nesting_restrict}{6}
\fexample{nesting_restrict}{6}