[llvm] [Offload] Add device UID (PR #164391)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 24 10:11:51 PDT 2025
================
@@ -293,6 +294,12 @@ struct CUDADeviceTy : public GenericDeviceTy {
if (auto Err = Plugin::check(Res, "error in cuDeviceGet: %s"))
return Err;
+ CUuuid UUID = {0};
+ Res = cuDeviceGetUuid(&UUID, Device);
+ if (auto Err = Plugin::check(Res, "error in cuDeviceGetUuid: %s"))
+ return Err;
+ setDeviceUidFromVendorUid(toHex(UUID.bytes, true));
----------------
ro-i wrote:
The expected use of the device UID are device traits that have been added in OpenMP 6.0. For example, there is the new env variable OMP_AVAILABLE_DEVICES where you can, for example, specify a list of device UIDs. Also, OMP_DEFAULT_DEVICE has been extended to also accept device UIDs (among much more). My two current PRs are just the start of a larger series of PRs :)
But there are also the new OpenMP api calls `omp_get_device_from_uid` and `omp_get_uid_from_device`, see https://github.com/llvm/llvm-project/pull/164392.
tldr: I'm not sure how often this stuff gets called, but it *should* not be performance sensitive. So, if you prefer to have the call to `cuDeviceGetUuid` / the HSA equivalent in `getDeviceUid()` and no precomputed `DeviceUid`, then that wouldn't be a problem in that regard.
https://github.com/llvm/llvm-project/pull/164391
More information about the llvm-commits
mailing list