yidawang commented on a change in pull request #4344: [ThreadPool] Solve thread 
transitions issue
URL: https://github.com/apache/incubator-tvm/pull/4344#discussion_r348118387
 
 

 ##########
 File path: src/runtime/threading_backend.cc
 ##########
 @@ -134,21 +134,28 @@ class ThreadGroup::Impl {
 #endif
     }
     if (exclude_worker0) {  // bind the master thread to core 0
-      cpu_set_t cpuset;
-      CPU_ZERO(&cpuset);
       if (reverse) {
-        CPU_SET(sorted_order_[sorted_order_.size() - 1], &cpuset);
+        core0_id_ = sorted_order_[sorted_order_.size() - 1];
       } else {
-        CPU_SET(sorted_order_[0], &cpuset);
+        core0_id_ = sorted_order_[0];
       }
+     pthread_atfork(nullptr, nullptr, 
ThreadGroup::Impl::BindMasterThreadToCore0);
+    }
+#endif
+  }
+
+  static void BindMasterThreadToCore0() {
+#if defined(__linux__) || defined(__ANDROID__)
+    cpu_set_t cpuset;
+    CPU_ZERO(&cpuset);
 
 Review comment:
   I think the idea here is to bind the master thread of the child process to 
"core 0" of the parent process at fork, otherwise there is no binding on the 
master thread. Actually, I think we can just simply never bind the master 
thread.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to