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* Contexts

At each point of an OpenMP* program, an OpenMP context exists that describes the following traits: the devices where parts of the program execute, the implementation supported functionality, such as target instruction sets, the active OpenMP constructs, and the available dynamic values.

A number of trait sets exist: construct, dynamic, device, implementation, and target_device. The category of the trait determines the syntax of the context selector used to match the trait.

At minimum, the following traits must be defined for each device and for all target device trait sets:

  • The construct trait set

    This is the set of pragma names of all enclosing constructs at that point in the program up to a omp target construct. Each enclosing directive name is a trait. Composite and combined constructs are added to the trait set as distinct constructs in the same nesting order specified by the construct.

    It is implementation defined if an implementation adds a omp dispatch construct to the trait set. If a dispatch trait is added, it is only added for the target call of the code. Constructs are ordered c1, … cN, with c1 being the outermost nested construct, and cN being the innermost nested construct. At a point in the program not enclosed in a omp target construct, the following rules are applied in the order shown:

    1. Procedures with the omp declare simd pragma have the omp simd trait added as the construct trait c1 for generated omp simd versions, increasing the size of the trait set by one.

    2. Procedures that are function variants generated by a omp declare variant pragma have the constructs c1 to cM added to the beginning of their set of construct traits as c1, … cM, increasing their construct trait set size by M.

    3. The omp target trait is added to the beginning of a device routine as c1 for versions of the procedure generated for target regions, increasing their construct trait set size by one.

    The clause list trait omp simd is defined with properties matching the clauses accepted in a omp declare simd pragma with the same names and semantics as the clauses. The omp simd trait minimally defines the simdlen property, and either the inbranch or the notinbranch property. Construct traits other than omp simd are non-property traits.

  • The device trait set

    This is the set that defines the characteristics of the device targeted by the compiler at that point in the program. A target-device set exists for each target device supported by an implementation, and includes traits that specify the characteristics of that device. The following traits must be defined for the device and target_device trait sets:

    • The kind (kind-name-list) trait indicates the kind of the device. Defined kind-name values are as follows:

      • any, which has the same effect as if no kind selector was specified

      • host, which indicates that the device is the host device

      • nohost, which indicates that the device is not the host device

      • Additional values defined in the OpenMP Additional Definitions document

    • The arch (architecture-name-list) specifies implementation defined architectures supported by the device.

    • The isa (isa-name-list) lists the implementation-defined instruction set architectures supported by the device.

    • The vendor (vendor-name-list) is a supported vendor-name value defined in OpenMP Additional Definitions document.

    • The target_device set also must include the device_num trait, which specifies the device number of the device.

    arch, isa, kind, and vendor traits in the device and target device traits are name-list traits.

  • The implementation trait set

    This is the set that contains traits that describe the supported functionality of the OpenMP implementation at that point in the program. The following traits can be defined:

    • extension (extension-name-list), which lists implementation-specific extensions to the OpenMP specification. Extension names are implementation defined.

    • vendor (vendor-name-list).

    • A requires (requires-clause-list) trait, which is a clause-list trait whose properties are the clauses that have been specified in the requires pragma prior to the point in the program, including any implementation-defined implicit requirements.

    The vendor and extension implementation set traits are name-list traits.

An implementation may define additional device, target_device, and implementation traits. These additional traits are extension traits.

The dynamic properties of a program at any point in its execution are specified by the dynamic trait set. The data state trait is a dynamic trait that refers to the complete data state of the program that can be accessed at runtime.