Foreign-runtime support for AMD GPUs (GNU libgomp) (original) (raw)
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’sinterop
directive or, implicitly, when invoking a declare variant
procedure that has the append_args
clause. In either case, theprefer_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 typeHSA_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:
Property | C data type | API routine | value (if constant) |
---|---|---|---|
fr_id | omp_interop_fr_t | int | omp_fr_hip |
fr_name | const char * | str | "hip" |
vendor | int | int | 1 |
vendor_name | const char * | str | "amd" |
device_num | int | int | |
platform | N/A | ||
device | hipDevice_t | int | |
device_context | hipCtx_t | ptr | |
targetsync | hipStream_t | ptr |
Available properties for an HSA interop object:
Property | C data type | API routine | value (if constant) |
---|---|---|---|
fr_id | omp_interop_fr_t | int | omp_fr_hsa |
fr_name | const char * | str | "hsa" |
vendor | int | int | 1 |
vendor_name | const char * | str | "amd" |
device_num | int | int | |
platform | N/A | ||
device | hsa_agent * | ptr | |
device_context | N/A | ||
targetsync | hsa_queue * | ptr |