[llvm-branch-commits] [llvm] users/adurang/rpc liboffload (PR #226448)
Alex Duran via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Sep 25 04:09:33 PDT 2026
https://github.com/adurang created https://github.com/llvm/llvm-project/pull/226448
<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
>From 822c0ae2dc1ae78d80ccca81e1b32b7049a2cc0d Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Mon, 7 Sep 2026 14:27:10 -0700
Subject: [PATCH 1/2] [offload][omp] Route RPC callback registration through
liboffload
Replace __tgt_register_rpc_callback's direct iteration over plugins
with olIteratePlatforms + olPlatformRegisterRPCCallback, and drop the
now-unused RPCServerTy::registerCallback export. Move the
initialized/has-devices guard that used to live in libomptarget into
olPlatformRegisterRPCCallback_impl.
---
offload/liboffload/src/OffloadImpl.cpp | 2 ++
offload/libomptarget/interface.cpp | 10 +++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index dc65214d87a6f..9a1febbc0e69b 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -429,6 +429,8 @@ Error olPlatformRegisterRPCCallback_impl(ol_platform_handle_t Platform,
ol_platform_rpc_cb_t Callback) {
if (auto Err = Platform->init())
return Err;
+ if (!Platform->Plugin || Platform->Plugin->getNumDevices() == 0)
+ return Error::success();
Platform->Plugin->getRPCServer().registerCallback(Callback);
return Error::success();
diff --git a/offload/libomptarget/interface.cpp b/offload/libomptarget/interface.cpp
index 5833925209fee..17726b889a55b 100644
--- a/offload/libomptarget/interface.cpp
+++ b/offload/libomptarget/interface.cpp
@@ -649,9 +649,13 @@ EXTERN void __tgt_register_rpc_callback(unsigned (*Callback)(void *,
if (!PM)
return;
- for (auto &Plugin : PM->plugins())
- if (Plugin.is_initialized() && Plugin.getNumDevices() > 0)
- Plugin.getRPCServer().registerCallback(Callback);
+ olIteratePlatforms(
+ [](ol_platform_handle_t Platform, void *Data) {
+ olPlatformRegisterRPCCallback(
+ Platform, reinterpret_cast<ol_platform_rpc_cb_t>(Data));
+ return true;
+ },
+ reinterpret_cast<void *>(Callback));
}
EXTERN void *__tgt_get_mapped_ptr(int64_t DeviceId, const void *HostPtr) {
>From 775392ce2dc0e0771aef514d7defb6079ba15990 Mon Sep 17 00:00:00 2001
From: "Duran, Alex" <alejandro.duran at intel.com>
Date: Tue, 8 Sep 2026 05:41:02 -0700
Subject: [PATCH 2/2] Remove number_of_devices
---
offload/plugins-nextgen/common/include/PluginInterface.h | 3 ---
offload/plugins-nextgen/common/src/PluginInterface.cpp | 2 --
2 files changed, 5 deletions(-)
diff --git a/offload/plugins-nextgen/common/include/PluginInterface.h b/offload/plugins-nextgen/common/include/PluginInterface.h
index 30ca13bdd01a3..0537a38de5cab 100644
--- a/offload/plugins-nextgen/common/include/PluginInterface.h
+++ b/offload/plugins-nextgen/common/include/PluginInterface.h
@@ -1734,9 +1734,6 @@ struct GenericPluginTy {
/// Returns non-zero if the \p Image is compatible with the device.
int32_t isDeviceCompatible(int32_t DeviceId, StringRef Image);
- /// Return the number of devices this plugin can support.
- int32_t number_of_devices();
-
/// Initializes the record and replay mechanism inside the plugin.
int32_t initialize_record_replay(int32_t DeviceId, int64_t MemorySize,
void *VAddr, bool IsRecord, bool IsNative,
diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp
index 355045de7541b..2ffea87faad3c 100644
--- a/offload/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp
@@ -1511,8 +1511,6 @@ int32_t GenericPluginTy::isDeviceCompatible(int32_t DeviceId, StringRef Image) {
}
}
-int32_t GenericPluginTy::number_of_devices() { return getNumDevices(); }
-
int32_t GenericPluginTy::initialize_record_replay(
int32_t DeviceId, int64_t MemorySize, void *VAddr, bool IsRecord,
bool IsNative, bool SaveOutput, bool EmitReport, const char *ReportFilename,
More information about the llvm-branch-commits
mailing list