diff options
author | Tobias Burnus <tburnus@baylibre.com> | 2024-09-20 09:25:33 +0200 |
---|---|---|
committer | Tobias Burnus <tburnus@baylibre.com> | 2024-09-20 09:25:33 +0200 |
commit | bf4a5efa80ef8438deb0a99c9a02b1f550aaf814 (patch) | |
tree | 6b94fba1e97e66e90fd328528ddce6415261ed2e /include | |
parent | 0be3f4546f9b92eb149a12303bd1f13569da7f28 (diff) | |
download | gcc-bf4a5efa80ef8438deb0a99c9a02b1f550aaf814.zip gcc-bf4a5efa80ef8438deb0a99c9a02b1f550aaf814.tar.gz gcc-bf4a5efa80ef8438deb0a99c9a02b1f550aaf814.tar.bz2 |
OpenMP: Add get_device_from_uid/omp_get_uid_from_device routines
Those TR13/OpenMP 6.0 routines permit a reproducible offloading to
a specific device by mapping an OpenMP device number to a
unique ID (UID). The GPU device UIDs should be universally unique,
the one for the host is not.
gcc/ChangeLog:
* omp-general.cc (omp_runtime_api_procname): Add
get_device_from_uid and omp_get_uid_from_device routines.
include/ChangeLog:
* cuda/cuda.h (cuDeviceGetUuid): Declare.
(cuDeviceGetUuid_v2): Add prototype.
libgomp/ChangeLog:
* config/gcn/target.c (omp_get_uid_from_device,
omp_get_device_from_uid): Add stub implementation.
* config/nvptx/target.c (omp_get_uid_from_device,
omp_get_device_from_uid): Likewise.
* fortran.c (omp_get_uid_from_device_,
omp_get_uid_from_device_8_): New functions.
* libgomp-plugin.h (GOMP_OFFLOAD_get_uid): Add prototype.
* libgomp.h (struct gomp_device_descr): Add 'uid' and 'get_uid_func'.
* libgomp.map (GOMP_6.0): New, includind the new UID routines.
* libgomp.texi (OpenMP Technical Report 13): Mark UID routines as 'Y'.
(Device Information Routines): Document new UID routines.
(Offload-Target Specifics): Document UID format.
* omp.h.in (omp_get_device_from_uid, omp_get_uid_from_device):
New prototype.
* omp_lib.f90.in (omp_get_device_from_uid, omp_get_uid_from_device):
New interface.
* omp_lib.h.in: Likewise.
* plugin/cuda-lib.def: Add cuDeviceGetUuid and cuDeviceGetUuid_v2 via
CUDA_ONE_CALL_MAYBE_NULL.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_uid): New.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_uid): New.
* target.c (str_omp_initial_device): New static var.
(STR_OMP_DEV_PREFIX): Define.
(gomp_get_uid_for_device, omp_get_uid_from_device,
omp_get_device_from_uid): New.
(gomp_load_plugin_for_device): DLSYM_OPT the function 'get_uid'.
(gomp_target_init): Set the device's 'uid' field to NULL.
* testsuite/libgomp.c/device_uid.c: New test.
* testsuite/libgomp.fortran/device_uid.f90: New test.
Diffstat (limited to 'include')
-rw-r--r-- | include/cuda/cuda.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/cuda/cuda.h b/include/cuda/cuda.h index 804d08c..3ade20f 100644 --- a/include/cuda/cuda.h +++ b/include/cuda/cuda.h @@ -201,6 +201,10 @@ typedef struct { size_t WidthInBytes, Height, Depth; } CUDA_MEMCPY3D_PEER; +typedef struct { + char bytes[16]; +} CUuuid; + #define cuCtxCreate cuCtxCreate_v2 CUresult cuCtxCreate (CUcontext *, unsigned, CUdevice); #define cuCtxDestroy cuCtxDestroy_v2 @@ -214,6 +218,9 @@ CUresult cuCtxPushCurrent (CUcontext); CUresult cuCtxSynchronize (void); CUresult cuCtxSetLimit (CUlimit, size_t); CUresult cuDeviceGet (CUdevice *, int); +/* _v2 was added in CUDA 11.4 and 'will supplant' the old one in 12.0. */ +CUresult cuDeviceGetUuid (CUuuid*, CUdevice); +CUresult cuDeviceGetUuid_v2 (CUuuid*, CUdevice); #define cuDeviceTotalMem cuDeviceTotalMem_v2 CUresult cuDeviceTotalMem (size_t *, CUdevice); CUresult cuDeviceGetAttribute (int *, CUdevice_attribute, CUdevice); |