summaryrefslogtreecommitdiff
path: root/offload/plugins-nextgen/common/include/PluginInterface.h
diff options
context:
space:
mode:
authorRobert Imschweiler <robert.imschweiler@amd.com>2025-11-04 20:15:47 +0100
committerGitHub <noreply@github.com>2025-11-04 20:15:47 +0100
commitdc94f2cbadfd192fe3d43bd00fd5a1d0ead5ab8d (patch)
tree6d9d687a21b2d1e14b0c16779e4ba6001ea9064f /offload/plugins-nextgen/common/include/PluginInterface.h
parent92a1eb37122fa24e3045fbabdea2bf87127cace5 (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/common/include/PluginInterface.h')
-rw-r--r--offload/plugins-nextgen/common/include/PluginInterface.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h
index f9bff9abd903..f9dcdea7213f 100644
--- a/offload/plugins-nextgen/common/include/PluginInterface.h
+++ b/offload/plugins-nextgen/common/include/PluginInterface.h
@@ -791,6 +791,9 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
/// this id is not unique between different plugins; they may overlap.
int32_t getDeviceId() const { return DeviceId; }
+ /// Get the unique identifier of the device.
+ const char *getDeviceUid() const { return DeviceUid.c_str(); }
+
/// Set the context of the device if needed, before calling device-specific
/// functions. Plugins may implement this function as a no-op if not needed.
virtual Error setContext() = 0;
@@ -989,9 +992,12 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
Error syncEvent(void *EventPtr);
virtual Error syncEventImpl(void *EventPtr) = 0;
+ /// Obtain information about the device.
+ Expected<InfoTreeNode> obtainInfo();
+ virtual Expected<InfoTreeNode> obtainInfoImpl() = 0;
+
/// Print information about the device.
Error printInfo();
- virtual Expected<InfoTreeNode> obtainInfoImpl() = 0;
/// Return true if the device has work that is either queued or currently
/// running
@@ -1204,6 +1210,14 @@ protected:
/// global device id and is not the device id visible to the OpenMP user.
const int32_t DeviceId;
+ /// The unique identifier of the device.
+ /// Per default, the unique identifier of the device is set to the device id,
+ /// combined with the plugin name, since the offload device id may overlap
+ /// between different plugins.
+ std::string DeviceUid;
+ /// Construct the device UID from the vendor (U)UID.
+ void setDeviceUidFromVendorUid(StringRef VendorUid);
+
/// The default grid values used for this device.
llvm::omp::GV GridValues;
@@ -1290,6 +1304,9 @@ struct GenericPluginTy {
return UserDeviceIds.at(DeviceId);
}
+ /// Get the UID for the host device.
+ static constexpr const char *getHostDeviceUid() { return "HOST"; }
+
/// Get the ELF code to recognize the binary image of this plugin.
virtual uint16_t getMagicElfBits() const = 0;