[llvm] [Offload][omp] Get Plugin active count and Device UID through liboffload (PR #230109)
Alex Duran via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 9 01:52:37 PDT 2026
================
@@ -86,6 +86,23 @@ DeviceTy::~DeviceTy() {
}
llvm::Error DeviceTy::init() {
+ size_t UidSize = 0;
+ if (!olGetDeviceInfoSize(DeviceHandle, OL_DEVICE_INFO_UID, &UidSize) &&
+ UidSize > 0) {
+ Uid.resize(UidSize);
+ if (olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_UID, UidSize, Uid.data()))
+ Uid.clear();
+ else
+ // Drop the null terminator from the size but keep it in the buffer, so
+ // that getUid() can be handed out as a C string.
+ Uid.pop_back();
+ }
+ if (Uid.empty()) {
+ ODBG(ODT_Init) << "Failed to get UID for device " << DeviceID;
+ // An empty SmallString is not guaranteed to be null-terminated.
+ Uid.c_str();
----------------
adurang wrote:
Sorry, I'm not sure what do you mean by the comment above but at this point ol is always initialized but we still need to handle failures.
Calling the plugin directly is exactly what we're trying avoid, that's why we go through liboffload. The goal is to decouple libomptarget from the plugins and only use liboffload (there's still a long way to go...).
https://github.com/llvm/llvm-project/pull/230109
More information about the llvm-commits
mailing list