HOME
| OPENMP API Specification: "Version 5.2 -- GIT rev 95b2e3a44"

7.2  Context Selectors

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 
   trait-property-clause 
   trait-property-expression 
   trait-property-extension 
 
trait-property-clause
   clause 
 
trait-property-name
   identifier 
   string-literal 
 
trait-property-expression 
   scalar-expression (for C/C++) 
   scalar-logical-expression (for Fortran) 
   scalar-integer-expression (for Fortran) 
 
trait-score
   score(score-expression
 
trait-property-extension
   trait-property-name 
   identifier(trait-property-extension[trait-property-extension[...]]
   constant integer expression  

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. Each selector that can be defined in the construct set is the directive-name of a context-matching construct. Each trait-property of the simd selector is a trait-property-clause. The syntax is the same as for a valid clause of the declare simd 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:

For the match clause of a declare variant 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 declare variant 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: