Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

OpenMP* Context Selectors

Context selectors define properties that can match an OpenMP* context. OpenMP defines different selectors sets, each set contains one or more different selectors.

Syntax

context-selector

Is trait-set-selector [, trait-set-selector [, . . . ]]

trait-set-selector

Is trait-set-selector-name= {trait-selector [, trait-selector [, . . .]]}

Note that the curly braces are part of the required syntax.

trait-set-selector-name

Is construct, device, implementation, target_device, or user.

trait-selector

Is trait-set-selector-name [ ( [trait-score : ] trait-property [, trait-property [, . . .]] ) ]

trait-score

Is score (score-expression)

score-expression

Is a scalar-integer-constant-expression with a non-negative value.

trait-property

Is trait-property-name

or trait-property-clause

or trait-property-expression

or trait-property-extension

trait-property-name

Is kind, isa, arch, or vendor

or a default-character-constant

trait-property-clause

Is a clause, as defined in the OpenMP 5.2 Specification.

trait-property-expression

Is a scalar-expression

or a scalar-integer-expression

trait-property-extension

Is trait-property-name

or identifier ( trait-property-extension [, trait-property-extension [, . . .]] )

or a constant-integer-expression

For trait-selectors that are name-list traits (kind, isa, and arch in the device and target_device trait sets), a specified trait-property should be trait-property-name. For these trait-selectors, at least one trait-property must be specified.

For trait-selectors that correspond to clause-list traits (a simd trait in the construct trait set, or a requires clause in the implementation trait set), a trait-property should be a trait-property-clause. The trait-property-clause syntax is the same as for a matching OpenMP clause. At least one trait-property must be specified for a requires selector.

The isa construct context selector set specifies the construct traits that should be active in the OpenMP context. The trait selectors that can be specified in a construct context selector are OpenMP directive names of context-matching constructs.

The syntax of a trait-property-clause for a trait-property of a simd trait-selector-name in a construct trait-selector set is that of a valid clause for a omp declare simd pragma with the same restriction for that clause.

The device and implementation selector sets define the traits that should be active in the trait sets of the OpenMP context. The target_device selector set specifies traits that should be active in the target device trait set for the device identified by the device_num selector. If the device_num selector is specified for target_device, only one trait-property-expression can be specified.

The kind selector of the device and the target_device selector sets can specify host, nohost, or any. If any is specified, neither host nor nohost can appear in the same selector.

atomic_default_mem_order can be specified as a selector for the implementation trait set. In this case, only a single trait-property can appear and it must be an identifier that is one of the valid arguments to the atomic_default_mem_order clause in a omp requires pragma.

The requires selector can also be specified as a selector of the implementation set. In this case, the syntax is the same as for a valid clause of a omp requires pragma, and the same restrictions apply.

The user selector defines a condition selector that specifies additional user-defined conditions. The condition selector must contain one trait-property-expression that is a logical expression; it must evaluate to true for the selector to be true. If the expression is not a constant expression, the selector is dynamic; otherwise, it is static.

The dynamic part of a context selector is its user selector set (if is it not static) and its target_device selector set. All other parts of the context selector are static.

In the match clause of a omp declare variant pragma, the following are rules for a context selector expression:

  • A reference to a formal parameter of the base function is a reference to the actual parmeter associated with the formal parameter.

  • Otherwise, a reference to a variable or function in an context selector expression is a reference to the variable or function that is accessible in the scope of the pragma in which the context selector appears.

Except in a construct selector set, each trait-property can be specified only once. Each trait-set-selector-name can appear once in context selector. A given trait-selector-name can appear only once in a context selector.

A trait-score cannot be specified for construct, device, or target_device trait selector sets.

The expression specified for device_num must evaluate to a non-negative integer value that is less than or equal to the value returned by a call to omp_get_num_devices ().