[llvm] [Offload] Store device info tree in device handle (PR #145913)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 27 03:03:53 PDT 2025
================
@@ -167,31 +167,39 @@ void initPlugins() {
for (auto DevNum = 0; DevNum < Platform.Plugin->number_of_devices();
DevNum++) {
if (Platform.Plugin->init_device(DevNum) == OFFLOAD_SUCCESS) {
- Platform.Devices.emplace_back(ol_device_impl_t{
- DevNum, &Platform.Plugin->getDevice(DevNum), &Platform});
+ auto Device = &Platform.Plugin->getDevice(DevNum);
+ auto Info = Device->obtainInfoImpl();
+ if (auto Err = Info.takeError())
+ return Err;
+ Platform.Devices.emplace_back(DevNum, Device, &Platform,
+ std::move(*Info));
}
}
}
// Add the special host device
auto &HostPlatform = Context->Platforms.emplace_back(
- ol_platform_impl_t{nullptr,
- {ol_device_impl_t{-1, nullptr, nullptr}},
- OL_PLATFORM_BACKEND_HOST});
+ ol_platform_impl_t{nullptr, OL_PLATFORM_BACKEND_HOST});
+ HostPlatform.Devices.emplace_back(-1, nullptr, nullptr, InfoTreeNode{});
Context->HostDevice()->Platform = &HostPlatform;
Context->TracingEnabled = std::getenv("OFFLOAD_TRACE");
Context->ValidationEnabled = !std::getenv("OFFLOAD_DISABLE_VALIDATION");
OffloadContextVal = Context;
+
+ return Plugin::success();
}
// TODO: We can properly reference count here and manage the resources in a more
// clever way
Error olInit_impl() {
static std::once_flag InitFlag;
- std::call_once(InitFlag, initPlugins);
+ std::optional<Error> InitResult{};
+ std::call_once(InitFlag, [&] { InitResult = initPlugins(); });
+ if (InitResult)
+ return std::move(*InitResult);
----------------
RossBrunton wrote:
https://github.com/llvm/llvm-project/pull/144055 That lives here; it's not been merged yet. I think it makes sense to get this device info change in first to unblock test failures.
https://github.com/llvm/llvm-project/pull/145913
More information about the llvm-commits
mailing list