Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
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

INTEROP

OpenMP* Fortran Compiler Directive: Identifies a foreign runtime context and identifies runtime characteristics of that context, enabling interoperability with it. This feature is only available for ifx.

Syntax

!$OMP INTEROP clause[[[,] clause]... ]

clause

Is one or more of the following:

  • DEPEND ([depend-modifier, ] dependence-type : locator-list)

    A DEPEND clause can appear only if TARGETSYNC appears as the interop-type in an action-clause, or if interop-var is initialized with the TARGETSYNC interop-type.

  • DEVICE (scalar-integer-expression)

    Only one DEVICE clause can appear in the directive. The integer-expression of the DEVICE clause must evaluate to a non-negative value equal to or less than the result of a call to the omp_get_num_devices runtime function.

  • NOWAIT

    Only one NOWAIT clause is permitted in the directive.

  • An action-clause

action-clause

Is one of the following:

  • INIT (modifier-list : interop-var)

    Causes the interop-var to be initialized to refer to the list of properties associated with the specified interop-type.

    The properties device_num, type, type_name, vendor, and vendor_name are available for all interop-types.

    If the specified device does not exist or it is not supported, the interop-var is initialized to the value of omp_interop_none, which is defined to be zero.

  • DESTROY (interop-var)

    Causes interop-var to be set to omp_interop_none after the resources associated with the interop-var are released. This action makes interop-var unusable until it is reinitialized by another INTEROP construct.

  • USE (interop-var)

    Causes interop-var to be used for the effects of the directive, but interop-var is not initialized, destroyed, or modified.

You must specify at least one action-clause. Each interop-type can appear at most once in an action-clause.

For the USE and DESTROY action-clauses, the interop-type is whatever interop-type was used when initializing the interop-var.

modifier-list

Is interop-type [[, interop-type] . . . ]

interop-type

Is one of the following:

  • PREFER_TYPE (preference-list)

  • TARGET

    Provides the following properties:

    • device - the foreign device handle

    • device_context - the foreign device context handle

    • platform - the handle to the foreign platform of the device

  • TARGETSYNC

    Enables synchronization between foreign tasks executing in the foreign execution context and OpenMP* tasks.

TARGET and TARGETSYNC may appear at most once in the clause. At least one modifier must be specified.

preference-list

Is a list of one or more foreign-runtime-ids, which can be character constants or integer constant expressions with kind type omp_interop_fr_kind. If you specify more than one foreign-runtime-id, they must be separated by commas.

The character values recognized by ifx are "opencl", "sycl", and "level_zero", which have corresponding integer values of 3, 4, and 6, respectively.

You can specify integer constants OMP_IFR_OPENCL, OMP_IFR_SYCL, and OMP_IFR_LEVEL_ZERO in the preference-list. Definitions for these integer constants are in module omp_lib.

Other character, integer, or named constants are accepted and silently ignored.

The list of foreign-runtime-ids is scanned in left-to-right lexical order. The left-most supported foreign-runtime-id in preference-list is used. If the implementation does not support any of the listed foreign-runtime-ids in preference-list, the behavior is unspecified.

interop-var

Is a scalar integer variable with kind type omp_interop_kind.

The interop-var of an INIT or DESTROY action-clause must not be a constant. The same interop-var cannot be specified in more than one action-clause of the INTEROP construct.

A task that encounters an INTEROP construct executes the region.

If a DEVICE clause is not specified, the behavior is as if a DEVICE clause is present with the integer value equal to the value of the internal control variable (ICV) default-device-var specified.

OpenMP* may interoperate with one or more foreign runtime environments using the INTEROP directive, the INTEROP clause on a DECLARE VARIANT directive, or the interoperability functions in the OpenMP* runtime API.

A task has an interoperability requirement set, which is a logical set of properties. Properties can be added to or removed from the set by different directives. The properties can be queried by other constructs that have interoperability semantics. The following properties can be added by a construct:

  • DEPEND - requires the construct enforce the synchronization relationship specified by the DEPEND clause

  • IS_DEVICE_PTR (list-item) - indicates that the list-item is a device pointer within the construct

  • NOWAIT - indicates that the construct is asynchronous

The DISPATCH directive can add properties to the interoperability requirement set.

The DECLARE VARIANT directive can remove properties from the interoperability requirement set.

If the interop-var is initialized with TARGETSYNC, an empty mergeable task is generated. DEPEND clauses apply to the generated task. If NOWAIT is omitted, the generated task is also an included task. The INTEROP construct guarantees ordered execution of the generated task with respect to foreign tasks executing in foreign contexts through the foreign synchronization object accessible through the TARGETSYNC property of the interop-var.

If a foreign task is created prior to encountering an INTEROP construct, the foreign task must complete execution before the generated task executes. If the creation of a foreign task occurs after an INTEROP construct is encountered, the foreign task cannot begin execution until the generated task finishes execution. The INTEROP construct imposes no ordering between the thread that encounters it and foreign tasks or OpenMP* tasks.