summaryrefslogtreecommitdiff
path: root/libc/startup
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-11 00:39:54 +0100
committerJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-11 00:41:51 +0100
commitf497611f436cbf5ae0157edcf498f62a136799cb (patch)
tree9e27d72e406e4979b710ffa943ae5c554d2d233f /libc/startup
parent958a3d8e2dec95a878dfc9d823861b3a6c674534 (diff)
downloadllvm-f497611f436cbf5ae0157edcf498f62a136799cb.tar.gz
[libc][rpc] Allocate locks array within process
Replaces the globals currently used. Worth changing to a bitmap before allowing runtime number of ports >> 64. One bit per port is likely to be cheap enough that sizing for the worst case is always fine, otherwise in the future we can change to dynamically allocating it. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D150309
Diffstat (limited to 'libc/startup')
-rw-r--r--libc/startup/gpu/amdgpu/start.cpp6
-rw-r--r--libc/startup/gpu/nvptx/start.cpp6
2 files changed, 4 insertions, 8 deletions
diff --git a/libc/startup/gpu/amdgpu/start.cpp b/libc/startup/gpu/amdgpu/start.cpp
index 84adb3b97527..9761c64cb318 100644
--- a/libc/startup/gpu/amdgpu/start.cpp
+++ b/libc/startup/gpu/amdgpu/start.cpp
@@ -15,8 +15,6 @@ extern "C" int main(int argc, char **argv, char **envp);
namespace __llvm_libc {
-static cpp::Atomic<uint32_t> lock[rpc::default_port_count] = {0};
-
extern "C" uintptr_t __init_array_start[];
extern "C" uintptr_t __init_array_end[];
extern "C" uintptr_t __fini_array_start[];
@@ -44,8 +42,8 @@ _begin(int argc, char **argv, char **env, void *in, void *out, void *buffer) {
// We need to set up the RPC client first in case any of the constructors
// require it.
__llvm_libc::rpc::client.reset(__llvm_libc::rpc::default_port_count,
- __llvm_libc::gpu::get_lane_size(),
- &__llvm_libc::lock, in, out, buffer);
+ __llvm_libc::gpu::get_lane_size(), in, out,
+ buffer);
// We want the fini array callbacks to be run after other atexit
// callbacks are run. So, we register them before running the init
diff --git a/libc/startup/gpu/nvptx/start.cpp b/libc/startup/gpu/nvptx/start.cpp
index 1d366dc829df..78cdc64ed967 100644
--- a/libc/startup/gpu/nvptx/start.cpp
+++ b/libc/startup/gpu/nvptx/start.cpp
@@ -15,8 +15,6 @@ extern "C" int main(int argc, char **argv, char **envp);
namespace __llvm_libc {
-static cpp::Atomic<uint32_t> lock[rpc::default_port_count] = {0};
-
extern "C" {
// Nvidia's 'nvlink' linker does not provide these symbols. We instead need
// to manually create them and update the globals in the loader implememtation.
@@ -48,8 +46,8 @@ _begin(int argc, char **argv, char **env, void *in, void *out, void *buffer) {
// We need to set up the RPC client first in case any of the constructors
// require it.
__llvm_libc::rpc::client.reset(__llvm_libc::rpc::default_port_count,
- __llvm_libc::gpu::get_lane_size(),
- &__llvm_libc::lock, in, out, buffer);
+ __llvm_libc::gpu::get_lane_size(), in, out,
+ buffer);
// We want the fini array callbacks to be run after other atexit
// callbacks are run. So, we register them before running the init