[llvm-branch-commits] [llvm] [offload][omp] Route RPC callback registration through liboffload (PR #226448)
Alex Duran via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Sep 29 08:52:43 PDT 2026
https://github.com/adurang updated https://github.com/llvm/llvm-project/pull/226448
>From 8ec47769a453dd2e77544d7a23038e06597e5e9d 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 | 6 +++++-
offload/libomptarget/interface.cpp | 10 +++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/offload/liboffload/src/OffloadImpl.cpp b/offload/liboffload/src/OffloadImpl.cpp
index a3e4166b13d14..4833c085acf77 100644
--- a/offload/liboffload/src/OffloadImpl.cpp
+++ b/offload/liboffload/src/OffloadImpl.cpp
@@ -485,7 +485,11 @@ Error olPlatformRegisterRPCCallback_impl(ol_platform_handle_t Platform,
ol_platform_rpc_cb_t Callback) {
if (Error Err = Platform->init())
return Err;
- Platform->Plugin->getRPCServer().registerCallback(Callback);
+ GenericPluginTy *Plugin = Platform->Plugin.get();
+ if (Plugin->getNumDevices() == 0)
+ return Error::success();
+
+ 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 f570e2f5cbe94021296736a5a1a87426e0ee189f 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