[llvm-branch-commits] [llvm] release/20.x: [Offload] Stop the RPC server faiilng with more than one GPU (#125982) (PR #125985)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 7 16:12:00 PST 2025


https://github.com/llvmbot updated https://github.com/llvm/llvm-project/pull/125985

>From dbb2699d2eee998e2a3d7862f7d633736bbbd77b Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 5 Feb 2025 20:51:28 -0600
Subject: [PATCH] [Offload] Stop the RPC server faiilng with more than one GPU
 (#125982)

Summary:
Pretty dumb mistake of me, forgot that this is run per-device and
per-plugin, which fell through the cracks with my testing because I have
two GPUs that use different plugins.

(cherry picked from commit 7a8779422dad058f11cd473d409f42e32859788d)
---
 offload/plugins-nextgen/common/src/PluginInterface.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/offload/plugins-nextgen/common/src/PluginInterface.cpp b/offload/plugins-nextgen/common/src/PluginInterface.cpp
index 16f510de3ecc5ca..57672b0223bec81 100644
--- a/offload/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/offload/plugins-nextgen/common/src/PluginInterface.cpp
@@ -1057,8 +1057,9 @@ Error GenericDeviceTy::setupRPCServer(GenericPluginTy &Plugin,
   if (auto Err = Server.initDevice(*this, Plugin.getGlobalHandler(), Image))
     return Err;
 
-  if (auto Err = Server.startThread())
-    return Err;
+  if (!Server.Thread->Running.load(std::memory_order_acquire))
+    if (auto Err = Server.startThread())
+      return Err;
 
   RPCServer = &Server;
   DP("Running an RPC server on device %d\n", getDeviceId());
@@ -1633,7 +1634,7 @@ Error GenericPluginTy::deinit() {
   if (GlobalHandler)
     delete GlobalHandler;
 
-  if (RPCServer && RPCServer->Thread->Running.load(std::memory_order_relaxed))
+  if (RPCServer && RPCServer->Thread->Running.load(std::memory_order_acquire))
     if (Error Err = RPCServer->shutDown())
       return Err;
 



More information about the llvm-branch-commits mailing list