aboutsummaryrefslogtreecommitdiff
path: root/libc/startup
diff options
context:
space:
mode:
authorJoseph Huber <jhuber6@vols.utk.edu>2023-03-10 16:48:53 -0600
committerJoseph Huber <jhuber6@vols.utk.edu>2023-03-17 12:55:31 -0500
commit8e4f9b1fcbfd5e747b0df9a2de511b43bfa13348 (patch)
tree4ab2a512d0d60cdd064638424f7852ed5b64f719 /libc/startup
parent8c040d0f4941d3557affda3550428b8712b69c92 (diff)
downloadllvm-8e4f9b1fcbfd5e747b0df9a2de511b43bfa13348.zip
llvm-8e4f9b1fcbfd5e747b0df9a2de511b43bfa13348.tar.gz
llvm-8e4f9b1fcbfd5e747b0df9a2de511b43bfa13348.tar.bz2
[libc] Add initial support for an RPC mechanism for the GPU
This patch adds initial support for an RPC client / server architecture. The GPU is unable to perform several system utilities on its own, so in order to implement features like printing or memory allocation we need to be able to communicate with the executing process. This is done via a buffer of "sharable" memory. That is, a buffer with a unified pointer that both the client and server can use to communicate. The implementation here is based off of Jon Chesterfields minimal RPC example in his work. We use an `inbox` and `outbox` to communicate between if there is an RPC request and to signify when work is done. We use a fixed-size buffer for the communication channel. This is fixed size so that we can ensure that there is enough space for all compute-units on the GPU to issue work to any of the ports. Right now the implementation is single threaded so there is only a single buffer that is not shared. This implementation still has several features missing to be complete. Such as multi-threaded support and asynchrnonous calls. Depends on D145912 Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D145913
Diffstat (limited to 'libc/startup')
-rw-r--r--libc/startup/gpu/amdgpu/CMakeLists.txt3
-rw-r--r--libc/startup/gpu/amdgpu/start.cpp6
2 files changed, 7 insertions, 2 deletions
diff --git a/libc/startup/gpu/amdgpu/CMakeLists.txt b/libc/startup/gpu/amdgpu/CMakeLists.txt
index be20237..d1c6fc7 100644
--- a/libc/startup/gpu/amdgpu/CMakeLists.txt
+++ b/libc/startup/gpu/amdgpu/CMakeLists.txt
@@ -2,11 +2,12 @@ add_startup_object(
crt1
SRC
start.cpp
+ DEPENDS
+ libc.src.__support.RPC.rpc_client
COMPILE_OPTIONS
-ffreestanding # To avoid compiler warnings about calling the main function.
-fno-builtin
-nogpulib # Do not include any GPU vendor libraries.
- -nostdinc
-mcpu=${LIBC_GPU_TARGET_ARCHITECTURE}
-emit-llvm # AMDGPU's intermediate object file format is bitcode.
--target=${LIBC_GPU_TARGET_TRIPLE}
diff --git a/libc/startup/gpu/amdgpu/start.cpp b/libc/startup/gpu/amdgpu/start.cpp
index 3be3745..cc30982 100644
--- a/libc/startup/gpu/amdgpu/start.cpp
+++ b/libc/startup/gpu/amdgpu/start.cpp
@@ -6,9 +6,13 @@
//
//===----------------------------------------------------------------------===//
+#include "src/__support/RPC/rpc_client.h"
+
extern "C" int main(int argc, char **argv);
extern "C" [[gnu::visibility("protected"), clang::amdgpu_kernel]] void
-_start(int argc, char **argv, int *ret) {
+_start(int argc, char **argv, int *ret, void *in, void *out, void *buffer) {
+ __llvm_libc::rpc::client.reset(in, out, buffer);
+
__atomic_fetch_or(ret, main(argc, argv), __ATOMIC_RELAXED);
}