This is an automated email from the ASF dual-hosted git repository.

tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 2acfa2c  [RPC][CPP] Add support of cpp RPC-server for Apple (#8224)
2acfa2c is described below

commit 2acfa2c08b43cd53d104da9f0b9e9dd5c2e2cc4f
Author: Alexey Gladyshev <[email protected]>
AuthorDate: Tue Jun 22 16:49:20 2021 +0300

    [RPC][CPP] Add support of cpp RPC-server for Apple (#8224)
---
 apps/cpp_rpc/rpc_server.cc | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/apps/cpp_rpc/rpc_server.cc b/apps/cpp_rpc/rpc_server.cc
index e299f10..5dc8410 100644
--- a/apps/cpp_rpc/rpc_server.cc
+++ b/apps/cpp_rpc/rpc_server.cc
@@ -22,7 +22,8 @@
  * \brief RPC Server implementation.
  */
 #include <tvm/runtime/registry.h>
-#if defined(__linux__) || defined(__ANDROID__)
+#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
+#include <signal.h>
 #include <sys/select.h>
 #include <sys/wait.h>
 #endif
@@ -52,7 +53,7 @@ namespace runtime {
  * \brief wait the child process end.
  * \param status status value
  */
-#if defined(__linux__) || defined(__ANDROID__)
+#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
 static pid_t waitPidEintr(int* status) {
   pid_t pid = 0;
   while ((pid = waitpid(-1, status, 0)) == -1) {
@@ -162,7 +163,7 @@ class RPCServer {
       }
 
       int timeout = GetTimeOutFromOpts(opts);
-#if defined(__linux__) || defined(__ANDROID__)
+#if defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__)
       // step 3: serving
       if (timeout != 0) {
         const pid_t timer_pid = fork();
@@ -219,6 +220,10 @@ class RPCServer {
       auto dur = high_resolution_clock::now() - start_time;
 
       LOG(INFO) << "Serve Time " << duration_cast<milliseconds>(dur).count() 
<< "ms";
+#else
+      LOG(WARNING) << "Unknown platform. It is not known how to bring up the 
subprocess."
+                   << " RPC will be launched in the main thread.";
+      ServerLoopProc(conn, addr, work_dir_);
 #endif
       // close from our side.
       LOG(INFO) << "Socket Connection Closed";

Reply via email to