[libc-commits] [libc] e6a350d - [libc] Replace the `PRINT_TO_STDERR` opcode for RPC printing.

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jun 5 17:28:37 PDT 2023


Author: Joseph Huber
Date: 2023-06-05T19:28:30-05:00
New Revision: e6a350df106cac06b22e23cedef0819a99f41ede

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

LOG: [libc] Replace the `PRINT_TO_STDERR` opcode for RPC printing.

A previous patch added general support for printing via the RPC
interface. we should consolidate this functionality and get rid of the
old opcode that was used for simple testing.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D152211

Added: 
    

Modified: 
    libc/src/__support/OSUtil/gpu/io.cpp
    libc/src/__support/RPC/rpc.h
    libc/utils/gpu/loader/Server.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/OSUtil/gpu/io.cpp b/libc/src/__support/OSUtil/gpu/io.cpp
index 0d8c9acc5211a..eb074a479deac 100644
--- a/libc/src/__support/OSUtil/gpu/io.cpp
+++ b/libc/src/__support/OSUtil/gpu/io.cpp
@@ -15,7 +15,7 @@
 namespace __llvm_libc {
 
 void write_to_stderr(cpp::string_view msg) {
-  rpc::Client::Port port = rpc::client.open<rpc::PRINT_TO_STDERR>();
+  rpc::Client::Port port = rpc::client.open<rpc::WRITE_TO_STDERR>();
   port.send_n(msg.data(), msg.size());
   port.recv([](rpc::Buffer *) { /* void */ });
   port.close();

diff  --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index 8e8fbd5860001..8be4e5dfb8ac5 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -39,10 +39,9 @@ enum Opcode : uint16_t {
   WRITE_TO_STREAM = 4,
   MALLOC = 5,
   FREE = 6,
-  PRINT_TO_STDERR = 7,
-  TEST_INCREMENT = 8,
-  TEST_INTERFACE = 9,
-  TEST_STREAM = 10,
+  TEST_INCREMENT = 7,
+  TEST_INTERFACE = 8,
+  TEST_STREAM = 9,
 };
 
 /// A fixed size channel used to communicate between the RPC client and server.

diff  --git a/libc/utils/gpu/loader/Server.h b/libc/utils/gpu/loader/Server.h
index a2bce068407b4..9286e55604c39 100644
--- a/libc/utils/gpu/loader/Server.h
+++ b/libc/utils/gpu/loader/Server.h
@@ -58,19 +58,6 @@ void handle_server(Alloc allocator, Dealloc deallocator) {
       }
       break;
     }
-    case rpc::Opcode::PRINT_TO_STDERR: {
-      uint64_t sizes[rpc::MAX_LANE_SIZE] = {0};
-      void *strs[rpc::MAX_LANE_SIZE] = {nullptr};
-      port->recv_n(strs, sizes, [&](uint64_t size) { return new char[size]; });
-      port->send([](rpc::Buffer *) { /* void */ });
-      for (uint64_t i = 0; i < rpc::MAX_LANE_SIZE; ++i) {
-        if (strs[i]) {
-          fwrite(strs[i], sizes[i], 1, stderr);
-          delete[] reinterpret_cast<uint8_t *>(strs[i]);
-        }
-      }
-      break;
-    }
     case rpc::Opcode::EXIT: {
       port->recv([](rpc::Buffer *buffer) {
         exit(reinterpret_cast<uint32_t *>(buffer->data)[0]);


        


More information about the libc-commits mailing list