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

 ##########
 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:
   We do not want to bind the master thread to core0? Instead, we want to avoid 
such binding and set its affinity to all cores.
   
   something like
   
   ```c++
   for (int i = 0; i < std::thread::hardware_concurrency(); ++i) {
      CPU_SET(i, &cpuset);
   }
   ```

----------------------------------------------------------------
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