[llvm] [Offload] Add device UID (PR #164391)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 22 08:22:30 PDT 2025


================
@@ -2069,6 +2069,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 (strcmp(Uuid + 3, "-XX") != 0)
----------------
jhuber6 wrote:

Can we do a StringRef `starts_with` and `drop_front`? UUID should probably just all be capitalized since it's an initialism.

https://github.com/llvm/llvm-project/pull/164391


More information about the llvm-commits mailing list