Skip to content

Commit

Permalink
[libc] Change RPC outbox stores to be relaxed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhuber6 committed Mar 24, 2023
1 parent c0d28d5 commit 53627ff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libc/src/__support/RPC/rpc.h
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down

0 comments on commit 53627ff

Please sign in to comment.