diff options
| author | Robert Imschweiler <robert.imschweiler@amd.com> | 2025-11-04 20:15:47 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-04 20:15:47 +0100 |
| commit | dc94f2cbadfd192fe3d43bd00fd5a1d0ead5ab8d (patch) | |
| tree | 6d9d687a21b2d1e14b0c16779e4ba6001ea9064f /offload/plugins-nextgen/amdgpu/src/rtl.cpp | |
| parent | 92a1eb37122fa24e3045fbabdea2bf87127cace5 (diff) | |
[Offload] Add device UID (#164391)
Introduced in OpenMP 6.0, the device UID shall be a unique identifier of
a device on a given system. (Not necessarily a UUID.) Since it is not
guaranteed that the (U)UIDs defined by the device vendor libraries, such
as HSA, do not overlap with those of other vendors, the device UIDs in
offload are always combined with the offload plugin name. In case the
vendor library does not specify any device UID for a given device, we
fall back to the offload-internal device ID.
The device UID can be retrieved using the `llvm-offload-device-info`
tool.
Diffstat (limited to 'offload/plugins-nextgen/amdgpu/src/rtl.cpp')
| -rw-r--r-- | offload/plugins-nextgen/amdgpu/src/rtl.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index 0b03ef534d27..928c6cd7569e 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -2083,6 +2083,20 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { return Err; ComputeUnitKind = GPUName; + // From the ROCm HSA documentation: + // Query the UUID of the agent. The value is an Ascii string with a maximum + // of 21 chars including NUL. The string value consists of two parts: header + // and body. The header identifies the device type (GPU, CPU, DSP) while the + // body encodes the UUID as a 16 digit hex string. + // + // Agents that do not support UUID will return the string "GPU-XX" or + // "CPU-XX" or "DSP-XX" depending on their device type. + char UUID[24] = {0}; + if (auto Err = getDeviceAttr(HSA_AMD_AGENT_INFO_UUID, UUID)) + return Err; + if (!StringRef(UUID).ends_with("-XX")) + setDeviceUidFromVendorUid(UUID); + // Get the wavefront size. uint32_t WavefrontSize = 0; if (auto Err = getDeviceAttr(HSA_AGENT_INFO_WAVEFRONT_SIZE, WavefrontSize)) |
