aboutsummaryrefslogtreecommitdiff
path: root/libc/startup
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-04-13 21:27:51 -0500
committerJoseph Huber <jhuber6@vols.utk.edu>2023-04-19 20:02:31 -0500
commitd0ff5e40308ee33936bfcc131f33adb4066b946f (patch)
tree1494580683bcc2b7a5ced602fda3bac15f1df8e8 /libc/startup
parentabd66d918ae95fbbdad076c38fe2ea6a459a9646 (diff)
downloadllvm-d0ff5e40308ee33936bfcc131f33adb4066b946f.zip
llvm-d0ff5e40308ee33936bfcc131f33adb4066b946f.tar.gz
llvm-d0ff5e40308ee33936bfcc131f33adb4066b946f.tar.bz2
[libc] Update RPC interface for system utilities on the GPU
This patch reworks the RPC interface to allow more generic memory operations using the shared better. This patch decomposes the entire RPC interface into opening a port and calling `send` or `recv` on it. The `send` function sends a single packet of the length of the buffer. The `recv` function is paired with the `send` call to then use the data. So, any aribtrary combination of sending packets is possible. The only restriction is that the client initiates the exchange with a `send` while the server consumes it with a `recv`. The operation of this is driven by two independent state machines that tracks the buffer ownership during loads / stores. We keep track of two so that we can transition between a send state and a recv state without an extra wait. State transitions are observed via bit toggling, e.g. This interface supports an efficient `send -> ack -> send -> ack -> send` interface and allows for the last send to be ignored without checking the ack. A following patch will add some more comprehensive testing to this interface. I I informally made an RPC call that simply incremented an integer and it took roughly 10 microsends to complete an RPC call. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D148288
Diffstat (limited to 'libc/startup')
-rw-r--r--libc/startup/gpu/amdgpu/start.cpp4
-rw-r--r--libc/startup/gpu/nvptx/start.cpp4
2 files changed, 6 insertions, 2 deletions
diff --git a/libc/startup/gpu/amdgpu/start.cpp b/libc/startup/gpu/amdgpu/start.cpp
index 9915dff..66f06b0 100644
--- a/libc/startup/gpu/amdgpu/start.cpp
+++ b/libc/startup/gpu/amdgpu/start.cpp
@@ -8,12 +8,14 @@
#include "src/__support/RPC/rpc_client.h"
+static __llvm_libc::cpp::Atomic<uint32_t> lock;
+
extern "C" int main(int argc, char **argv, char **envp);
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
_start(int argc, char **argv, char **envp, int *ret, void *in, void *out,
void *buffer) {
- __llvm_libc::rpc::client.reset(in, out, buffer);
+ __llvm_libc::rpc::client.reset(&lock, in, out, buffer);
__atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
}
diff --git a/libc/startup/gpu/nvptx/start.cpp b/libc/startup/gpu/nvptx/start.cpp
index b09d6f6..9939c6e 100644
--- a/libc/startup/gpu/nvptx/start.cpp
+++ b/libc/startup/gpu/nvptx/start.cpp
@@ -8,12 +8,14 @@
#include "src/__support/RPC/rpc_client.h"
+static __llvm_libc::cpp::Atomic<uint32_t> lock;
+
extern "C" int main(int argc, char **argv, char **envp);
extern "C" [[gnu::visibility("protected")]] __attribute__((nvptx_kernel)) void
_start(int argc, char **argv, char **envp, int *ret, void *in, void *out,
void *buffer) {
- __llvm_libc::rpc::client.reset(in, out, buffer);
+ __llvm_libc::rpc::client.reset(&lock, in, out, buffer);
__atomic_fetch_or(ret, main(argc, argv, envp), __ATOMIC_RELAXED);
}