Context selectors are used to define the properties that can match an OpenMP context. OpenMP defines
different sets of selectors, each containing different selectors.
The syntax for a context selector is context-selector-specification as described in the following
grammar:
context-selector-specification: trait-set-selector[,trait-set-selector[,...]] trait-set-selector: trait-set-selector-name={trait-selector[,trait-selector[,...]]} trait-selector: trait-selector-name[([trait-score:]trait-property[,trait-property[,...]])] trait-property: trait-property-name or trait-property-clause or trait-property-expression or trait-property-extension trait-property-clause: clause trait-property-name: identifier or string-literal trait-property-expression scalar-expression(forC/C++) or scalar-logical-expression(forFortran) or scalar-integer-expression(forFortran) trait-score: score(score-expression) trait-property-extension: trait-property-name or identifier(trait-property-extension[,trait-property-extension[,...]]) or constantintegerexpression
For trait selectors that correspond to name-list traits, each trait-property should be trait-property-name and
for any value that is a valid identifier both the identifier and the corresponding string literal (for C/C++) and
the corresponding char-literal-constant (for Fortran) representation are considered representations of the
same value.
For trait selectors that correspond to clause-list traits, each trait-property should be trait-property-clause.
The syntax is the same as for the matching OpenMP clause.
The construct selector set defines the construct traits that should be active in the OpenMP context. The
following selectors can be defined in the construct set: target; teams; parallel; for (in
C/C++); do (in Fortran); simd and dispatch. Each trait-property of the simd selector is a
trait-property-clause. The syntax is the same as for a valid clause of the declaresimd directive and the
restrictions on the clauses from that directive apply. The construct selector is an ordered list
c1, …, cN.
The device and implementation selector sets define the traits that should be active in the
corresponding trait set of the OpenMP context. The target_device selector set defines the traits that
should be active in the target_device trait set for the device that the specified device_num selector
identifies. The same traits that are defined in the corresponding traits sets can be used as selectors with the
same properties. The kind selector of the device and target_device selector sets can also specify
the value any, which is as if no kind selector was specified. If a device_num selector does not appear in
the target_device selector set then a device_num selector that specifies the value of the
default-device-var ICV is implied. For the device_num selector of the target_device selector set, a
single trait-property-expression must be specified. For the atomic_default_mem_order selector of
the implementation set, a single trait-property must be specified as an identifier equal to one of the
valid arguments to the atomic_default_mem_order clause on the requires directive. For the
requires selector of the implementation set, each trait-property is a trait-property-clause. The
syntax is the same as for a valid clause of the requires directive and the restrictions on the clauses from
that directive apply.
The user selector set defines the condition selector that provides additional user-defined
conditions.
The condition selector contains a single trait-property-expression that must evaluate to true for the
selector to be true.
Any non-constant expression that is evaluated to determine the suitability of a variant is evaluated according
to the data state trait in the dynamic trait set of the OpenMP context.
The user selector set is dynamic if the condition selector is present and the expression in the
condition selector is not a constant expression; otherwise, it is static.
All parts of a context selector define the static part of the context selector except the following parts, which
define the dynamic part of a context selector:
Its
user
selector
set
if
it
is
dynamic;
and
Its
target_device
selector
set.
For the match clause of a declarevariant directive, any argument of the base function that is
referenced in an expression that appears in the context selector is treated as a reference to the
expression that is passed into that argument at the call to the base function. Otherwise, a variable or
procedure reference in an expression that appears in a context selector is a reference to the variable
or procedure of that name that is visible at the location of the directive on which the selector
appears.
Each occurrence of the this pointer in an expression in a context selector that appears in the match
clause of a declarevariant directive is treated as an expression that is the address of the object on
which the associated base function is invoked.
Implementations can allow further selectors to be specified. Each specified trait-property for these
implementation-defined selectors should be trait-property-extension. Implementations can ignore specified
selectors that are not those described in this section.
Restrictions
Restrictions to context selectors are as follows:
Each
trait-property
can
only
be
specified
once
in
a
trait-selector
other
than
the
construct
selector
set.
Each
trait-set-selector-name
can
only
be
specified
once.
Each
trait-selector-name
can
only
be
specified
once.
A
trait-score
cannot
be
specified
in
traits
from
the
construct,
device
or
target_devicetrait-selector-sets.
A
score-expression
must
be
a
non-negative
constant
integer
expression.
The
expression
of
a
device_num
trait
must
evaluate
to
a
non-negative
integer
value
that
is
less
than
or
equal
to
the
value
of
omp_get_num_devices().
A
variable
or
procedure
that
is
referenced
in
an
expression
that
appears
in
a
context
selector
must
be
visible
at
the
location
of
the
directive
on
which
the
selector
appears
unless
the
directive
is
a
declarevariant
directive
and
the
variable
is
an
argument
of
the
associated
base
function.
If
trait-propertyany
is
specified
in
the
kindtrait-selector
of
the
device
or
target_device
selector
set,
no
other
trait-property
may
be
specified
in
the
same
selector.
For
a
trait-selector
that
corresponds
to
a
name-list
trait,
at
least
one
trait-property
must
be
specified.
For
a
trait-selector
that
corresponds
to
a
non-property
trait,
no
trait-property
may
be
specified.
For
the
requires
selector
of
the
implementation
selector
set,
at
least
one
trait-property
must
be
specified.