[libc-commits] [PATCH] D152211: [libc] Replace the `PRINT_TO_STDERR` opcode for RPC printing.

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Jun 5 16:57:30 PDT 2023


jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, sivachandra, lntue, michaelrj.
Herald added subscribers: libc-commits, tschuett.
Herald added projects: libc-project, All.
jhuber6 requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152211

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


Index: libc/utils/gpu/loader/Server.h
===================================================================
--- libc/utils/gpu/loader/Server.h
+++ libc/utils/gpu/loader/Server.h
@@ -58,19 +58,6 @@
       }
       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]);
Index: libc/src/__support/RPC/rpc.h
===================================================================
--- libc/src/__support/RPC/rpc.h
+++ libc/src/__support/RPC/rpc.h
@@ -39,10 +39,9 @@
   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.
Index: libc/src/__support/OSUtil/gpu/io.cpp
===================================================================
--- libc/src/__support/OSUtil/gpu/io.cpp
+++ 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();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152211.528634.patch
Type: text/x-patch
Size: 1884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230605/3b3ec4a5/attachment.bin>


More information about the libc-commits mailing list