This section describes a set of restrictions on the nesting of regions. The restrictions on nesting are as
follows:
A
worksharing
region
may
not
be
closely
nested
inside
a
worksharing,
task,
taskloop,
critical,
ordered,
atomic,
or
masked
region.
A
barrier
region
may
not
be
closely
nested
inside
a
worksharing,
task,
taskloop,
critical,
ordered,
atomic,
or
masked
region.
A
masked
region
may
not
be
closely
nested
inside
a
worksharing,
atomic,
task,
or
taskloop
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
without
any
clause
or
with
the
threads
or
depend
clause
may
not
be
closely
nested
inside
a
critical,
ordered,
loop,
atomic,
task,
or
taskloop
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
without
the
simd
clause
specified
must
be
closely
nested
inside
a
worksharing-loop
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
with
the
simd
clause
specified
must
be
closely
nested
inside
a
simd
or
worksharing-loop
SIMD
region.
An
ordered
region
that
corresponds
to
an
ordered
construct
with
both
the
simd
and
threads
clauses
must
be
closely
nested
inside
a
worksharing-loop
SIMD
region
or
closely
nested
inside
a
worksharing-loop
and
simd
region.
A
critical
region
may
not
be
nested
(closely
or
otherwise)
inside
a
critical
region
with
the
same
name.
This
restriction
is
not
sufficient
to
prevent
deadlock.
OpenMP
constructs
may
not
be
encountered
during
execution
of
an
atomic
region.
The
only
OpenMP
constructs
that
can
be
encountered
during
execution
of
a
simd
(or
worksharing-loop
SIMD)
region
are
the
atomic
construct,
the
loop
construct
without
a
defined
binding
region,
the
simd
construct
and
the
ordered
construct
with
the
simd
clause.
If
a
targetupdate,
targetdata,
targetenterdata,
or
targetexitdata
construct
is
encountered
during
execution
of
a
target
region,
the
behavior
is
unspecified.
If
a
target
construct
is
encountered
during
execution
of
a
target
region
and
a
device
clause
in
which
the
ancestor
device-modifier
appears
is
not
present
on
the
construct,
the
behavior
is
unspecified.
A
teams
region
must
be
strictly
nested
either
within
the
implicit
parallel
region
that
surrounds
the
whole
OpenMP
program
or
within
a
target
region.
If
a
teams
construct
is
nested
within
a
target
construct,
that
target
construct
must
contain
no
statements,
declarations
or
directives
outside
of
the
teams
construct.
distribute
regions,
including
any
distribute
regions
arising
from
composite
constructs,
parallel
regions,
including
any
parallel
regions
arising
from
combined
constructs,
loop
regions,
omp_get_num_teams()
regions,
and
omp_get_team_num()
regions
are
the
only
OpenMP
regions
that
may
be
strictly
nested
inside
the
teams
region.
A
loop
region
that
binds
to
a
teams
region
must
be
strictly
nested
inside
a
teams
region.
A
distribute
region
must
be
strictly
nested
inside
a
teams
region.
If
cancel-directive-name
is
taskgroup,
the
cancel
construct
must
be
closely
nested
inside
a
task
construct
and
the
cancel
region
must
be
closely
nested
inside
a
taskgroup
region.
Otherwise,
the
cancel
construct
must
be
closely
nested
inside
an
OpenMP
construct
for
which
directive-name
is
cancel-directive-name.
A
cancellationpoint
construct
for
which
cancel-directive-name
is
taskgroup
must
be
closely
nested
inside
a
task
construct,
and
the
cancellationpoint
region
must
be
closely
nested
inside
a
taskgroup
region.
Otherwise,
a
cancellationpoint
construct
must
be
closely
nested
inside
an
OpenMP
construct
for
which
directive-name
is
cancel-directive-name.
The
only
constructs
that
may
be
encountered
inside
a
region
that
corresponds
to
a
construct
with
an
order
clause
that
specifies
concurrent
are
the
loop,
parallel
and
simd
constructs,
and
combined
constructs
for
which
directive-name-A
is
parallel.
A
region
that
corresponds
to
a
construct
with
an
order
clause
that
specifies
concurrent
may
not
contain
calls
to
the
OpenMP
Runtime
API
or
to
procedures
that
contain
OpenMP
directives.