SummaryA metadirective is a directive that can specify multiple directive variants of which one
may be conditionally selected to replace the metadirective based on the enclosing OpenMP
context.
Syntax
The syntax of a metadirective takes one of the following forms:
In the when clause, context-selector-specification specifies a context selector (see Section 2.3.2).
In the when and default clauses, directive-variant has the following form and specifies a directive
variant that specifies an OpenMP directive with clauses that apply to it.
directive-name[clause[[,]clause]...]
DescriptionA metadirective is a directive that behaves as if it is either ignored or replaced by
the directive variant specified in one of the when or default clauses that appears on the
metadirective.
The OpenMP context for a given metadirective is defined according to Section 2.3.1. For each when clause
that appears on a metadirective, the specified directive variant, if present, is a candidate to replace the
metadirective if the corresponding context selector is compatible with the OpenMP context
according to the matching rules defined in Section 2.3.3. If only one compatible context selector
specified by a when clause has the highest score and it specifies a directive variant, the directive
variant will replace the metadirective. If more than one when clause specifies a compatible
context selector that has the highest computed score and at least one specifies a directive variant,
the first directive variant specified in the lexical order of those when clauses will replace the
metadirective.
If no context selector from any when clause is compatible with the OpenMP context and a
default clause is present, the directive variant specified in the default clause will replace the
metadirective.
If a directive variant is not selected to replace a metadirective according to the above rules, the metadirective
has no effect on the execution of the program.
The beginmetadirective directive behaves identically to the metadirective directive, except
that the directive syntax for the specified directive variants must accept a paired enddirective. For
any directive variant that is selected to replace the beginmetadirective directive, the
endmetadirective directive will be implicitly replaced by its paired enddirective to demarcate the
statements that are affected by or are associated with the directive variant. If no directive variant is selected
to replace the beginmetadirective directive, its paired endmetadirective directive is
ignored.
RestrictionsRestrictions to metadirectives are as follows:
The
directive
variant
appearing
in
a
when
or
default
clause
must
not
specify
a
metadirective,
beginmetadirective,
or
endmetadirective
directive.
The
context
selector
that
appears
in
a
when
clause
must
not
specify
any
properties
for
the
simd
selector.
Any
replacement
that
occurs
for
a
metadirective
must
not
result
in
a
non-conforming
OpenMP
program.
Any
directive
variant
that
is
specified
by
a
when
or
default
clause
on
a
beginmetadirective
directive
must
be
an
OpenMP
directive
that
has
a
paired
enddirective,
and
the
beginmetadirective
directive
must
have
a
paired
endmetadirective
directive.
The
default
clause
may
appear
at
most
once
on
a
metadirective.