12.1.1 OpenMP interop – Foreign-Runtime Support for AMD GPUs

On AMD GPUs, the foreign runtimes are HIP (C++ Heterogeneous-Compute Interface for Portability) and HSA (Heterogeneous System Architecture), where HIP is the default. The interop object is created using OpenMP’s interop directive or, implicitly, when invoking a declare variant procedure that has the append_args clause. In either case, the prefer_type modifier determines whether HIP or HSA is used.

When specifying the targetsync modifier: For HIP, a stream is created using hipStreamCreate. For HSA, a queue is created of type HSA_QUEUE_TYPE_MULTI with a queue size of 64.

Invoke the Interoperability Routines on an interop object to obtain the following properties. For properties with integral (int), pointer (ptr), or string (str) data type, call omp_get_interop_int, omp_get_interop_ptr, or omp_get_interop_str, respectively. Note that device_num is the OpenMP device number while device is the HIP device number or HSA device handle.

When using HIP with C and C++, the __HIP_PLATFORM_AMD__ preprocessor macro must be defined before including the HIP header files.

For the API routine call, add the prefix omp_ipr_ to the property name; for instance:

omp_interop_rc_t ret;
int device_num = omp_get_interop_int (my_interop_obj, omp_ipr_device_num, &ret);

Available properties for an HIP interop object:

PropertyC data typeAPI routinevalue (if constant)
fr_idomp_interop_fr_tintomp_fr_hip
fr_nameconst char *str"hip"
vendorintint1
vendor_nameconst char *str"amd"
device_numintint
platformN/A
devicehipDevice_tint
device_contexthipCtx_tptr
targetsynchipStream_tptr

Available properties for an HSA interop object:

PropertyC data typeAPI routinevalue (if constant)
fr_idomp_interop_fr_tintomp_fr_hsa
fr_nameconst char *str"hsa"
vendorintint1
vendor_nameconst char *str"amd"
device_numintint
platformN/A
devicehsa_agent *ptr
device_contextN/A
targetsynchsa_queue *ptr