HOME
| OPENMP API Specification: Version 5.1 November 2020

2.15.1  interop Construct

Summary The interop construct retrieves interoperability properties from the OpenMP implementation to enable interoperability with foreign execution contexts. The interop construct is a stand-alone directive.

Syntax In the following syntax, interop-type is the type of interoperability information being requested or used by the interop construct, and action-clause is a clause that indicates the action to take with respect to that interop object.

SVG-Viewer needed.

The syntax of the interop construct is as follows:  

 
#pragma omp interop clause[ [ [,] clause] ... ] new-line  

where clause is action-clause or one of the following:  

 
device(integer-expression) 
depend([depend-modifier,] dependence-type : locator-list)  

where action-clause is one of the following:  

 
init([interop-modifier, ]interop-type[[, interop-type] ... ]:interop-var) 
destroy(interop-var) 
use(interop-var) 
nowait  

where interop-var is a variable of type omp_interop_t, and interop-type is one of the following:  

 
target 
targetsync  

and interop-modifier is one of the following:  

 
prefer_type(preference-list)  

where preference-list is a comma separated list for which each item is a foreign-runtime-id, which is a base language string literal or a compile-time constant integral expression. Allowed values for foreign-runtime-id include the names (as string literals) and integer values specified in the OpenMP Additional Definitions document and the corresponding omp_ifr_name constants of omp_interop_fr_t type; implementation-defined values may also be supported.

SVG-Viewer needed.

SVG-Viewer needed.

The syntax of the interop construct is as follows:  

 
!$omp interop clause[ [ [,] clause] ... ]  

where clause is action-clause or one of the following:  

 
device(integer-expression) 
depend([depend-modifier,] dependence-type : locator-list)  

where action-clause is one of the following:  

 
init([interop-modifier, ]interop-type[[, interop-type] ... ]:interop-var) 
destroy(interop-var) 
use(interop-var) 
nowait  

where interop-var is a scalar integer variable of kind omp_interop_kind, and interop-type is one of the following:  

 
target 
targetsync  

and interop-modifier is one of the following:  

 
prefer_type(preference-list)  

where preference-list is a comma separated list for which each item is a foreign-runtime-id, which is a base language string literal or a compile-time constant integral expression. Allowed values for foreign-runtime-id include the names (as string literals) and integer values specified in the OpenMP Additional Definitions document and the corresponding omp_ifr_name integer constants of kind omp_interop_fr_kind; implementation-defined values may also be supported.

SVG-Viewer needed.

Binding The binding task set for an interop region is the generating task. The interop region binds to the region of the generating task.

Description When an interop construct is encountered, the encountering task executes the region. If no device clause is present, the behavior is as if the device clause appears with an expression equal to the value of the default-device-var ICV.

If the initaction-clause is specified, the interop-var is initialized to refer to the list of properties associated with the given interop-type. For any interop-type, the properties type, type_name, vendor, vendor_name and device_num will be available. If the implementation is unable to initialize the interop-var, it will be initialized to the value of omp_interop_none, which is defined to be zero.

The targetsyncinterop-type will additionally provide the targetsync property, which is the handle to a foreign synchronization object for enabling synchronization between OpenMP tasks and foreign tasks that execute in the foreign execution context.

The targetinterop-type will additionally provide the following properties:

If the destroyaction-clause is specified, the interop-var is set to the value of omp_interop_none after resources associated with interop-var are released. The object referred to by the interop-var will be unusable after destruction and the effect of using values associated with it is unspecified until interop-var is initialized again by another interop construct.

If the useaction-clause is specified, the interop-var is used for other effects of this directive but is not initialized, destroyed or otherwise modified.

For the destroy or useaction-clause, the interop-type is inferred based on the interop-type used to initialize the interop-var.

If the interop-type specified is targetsync, or the interop-var was initialized with targetsync, an empty mergeable task is generated. If the nowait clause is not present on the construct then the task is also an included task. Any depend clauses that are present on the construct apply to the generated task. The interop construct ensures an ordered execution of the generated task relative to foreign tasks executed in the foreign execution context through the foreign synchronization object accessible through the targetsync property of interop-var. When the creation of the foreign task precedes the encountering of an interop construct in happens before order (see Section 1.4.5), the foreign task must complete execution before the generated task begins execution. Similarly, when the creation of a foreign task follows the encountering of an interop construct in happens before order, the foreign task must not begin execution until the generated task completes execution. No ordering is imposed between the encountering thread and either foreign tasks or OpenMP tasks by the interop construct.

If the prefer_typeinterop-modifier clause is specified, the first supported foreign-runtime-id in preference-list in left-to-right order is used. The foreign-runtime-id that is used if the implementation does not support any of the items in preference-list is implementation defined.

Restrictions Restrictions to the interop construct are as follows:

Cross References