[libc-commits] [libc] 53627ff - [libc] Change RPC outbox stores to be relaxed

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Fri Mar 24 07:39:00 PDT 2023


Author: Joseph Huber
Date: 2023-03-24T09:38:51-05:00
New Revision: 53627ffb3cc9bfefe3fbfb2356a736593b90b77e

URL: https://github.com/llvm/llvm-project/commit/53627ffb3cc9bfefe3fbfb2356a736593b90b77e
DIFF: https://github.com/llvm/llvm-project/commit/53627ffb3cc9bfefe3fbfb2356a736593b90b77e.diff

LOG: [libc] Change RPC outbox stores to be relaxed

Summary:
These stored previously used `RELEASE`. This was done originally to
ensure that the stores to the shared memory buffer were flushed prior to
signaling that the other side can begin accessing it. However, this
should be accomplished by the memory fence above the store. This change
is required because NVPTX does not support non-relaxed atomics used on
unified shared memory.

Added: 
    

Modified: 
    libc/src/__support/RPC/rpc.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index d536de49bf5ff..8ebf40af3e265 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -81,7 +81,7 @@ template <typename F, typename U> void Client::run(F fill, U use) {
   if (!in & !out) {
     fill(buffer);
     atomic_thread_fence(cpp::MemoryOrder::RELEASE);
-    outbox->store(1, cpp::MemoryOrder::RELEASE);
+    outbox->store(1, cpp::MemoryOrder::RELAXED);
     out = 1;
   }
   // Wait for the server to work on the buffer and respond.
@@ -94,7 +94,7 @@ template <typename F, typename U> void Client::run(F fill, U use) {
   if (in & out) {
     use(buffer);
     atomic_thread_fence(cpp::MemoryOrder::RELEASE);
-    outbox->store(0, cpp::MemoryOrder::RELEASE);
+    outbox->store(0, cpp::MemoryOrder::RELAXED);
     out = 0;
   }
   // Wait for the server to signal the end of the protocol.
@@ -123,7 +123,7 @@ template <typename W, typename C> bool Server::handle(W work, C clean) {
   if (in & !out) {
     work(buffer);
     atomic_thread_fence(cpp::MemoryOrder::RELEASE);
-    outbox->store(1, cpp::MemoryOrder::RELEASE);
+    outbox->store(1, cpp::MemoryOrder::RELAXED);
     out = 1;
   }
   // Wait for the client to use the buffer and respond.
@@ -136,7 +136,7 @@ template <typename W, typename C> bool Server::handle(W work, C clean) {
   if (!in & out) {
     clean(buffer);
     atomic_thread_fence(cpp::MemoryOrder::RELEASE);
-    outbox->store(0, cpp::MemoryOrder::RELEASE);
+    outbox->store(0, cpp::MemoryOrder::RELAXED);
     out = 0;
   }
 


        


More information about the libc-commits mailing list