aboutsummaryrefslogtreecommitdiff
path: root/offload/plugins-nextgen/common/src/PluginInterface.cpp
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/src/PluginInterface.cpp
parent92a1eb37122fa24e3045fbabdea2bf87127cace5 (diff)
downloadllvm-dc94f2cbadfd192fe3d43bd00fd5a1d0ead5ab8d.zip
llvm-dc94f2cbadfd192fe3d43bd00fd5a1d0ead5ab8d.tar.gz
llvm-dc94f2cbadfd192fe3d43bd00fd5a1d0ead5ab8d.tar.bz2
[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/src/PluginInterface.cpp')
-rw-r--r--offload/plugins-nextgen/common/src/PluginInterface.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp
index 36d643b..d7e5a21 100644
--- a/offload/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp
@@ -715,6 +715,10 @@ GenericDeviceTy::GenericDeviceTy(GenericPluginTy &Plugin, int32_t DeviceId,
DeviceId(DeviceId), GridValues(OMPGridValues),
PeerAccesses(NumDevices, PeerAccessState::PENDING), PeerAccessesLock(),
PinnedAllocs(*this), RPCServer(nullptr) {
+ // Conservative fall-back to the plugin's device uid for the case that no real
+ // vendor (u)uid will become available later.
+ setDeviceUidFromVendorUid(std::to_string(static_cast<uint64_t>(DeviceId)));
+
#ifdef OMPT_SUPPORT
OmptInitialized.store(false);
// Bind the callbacks to this device's member functions
@@ -1524,15 +1528,22 @@ Error GenericDeviceTy::enqueueHostCall(void (*Callback)(void *), void *UserData,
return Err;
}
+Expected<InfoTreeNode> GenericDeviceTy::obtainInfo() {
+ auto InfoOrErr = obtainInfoImpl();
+ if (InfoOrErr)
+ InfoOrErr->add("UID", getDeviceUid(), "", DeviceInfo::UID);
+ return InfoOrErr;
+}
+
Error GenericDeviceTy::printInfo() {
- auto Info = obtainInfoImpl();
+ auto InfoOrErr = obtainInfo();
// Get the vendor-specific info entries describing the device properties.
- if (auto Err = Info.takeError())
+ if (auto Err = InfoOrErr.takeError())
return Err;
// Print all info entries.
- Info->print();
+ InfoOrErr->print();
return Plugin::success();
}
@@ -1603,6 +1614,10 @@ Expected<bool> GenericDeviceTy::isAccessiblePtr(const void *Ptr, size_t Size) {
return isAccessiblePtrImpl(Ptr, Size);
}
+void GenericDeviceTy::setDeviceUidFromVendorUid(StringRef VendorUid) {
+ DeviceUid = std::string(Plugin.getName()) + "-" + std::string(VendorUid);
+}
+
Error GenericPluginTy::init() {
if (Initialized)
return Plugin::success();