tqchen commented on a change in pull request #4344: [ThreadPool] Solve thread
transitions issue
URL: https://github.com/apache/incubator-tvm/pull/4344#discussion_r348122833
##########
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:
OK, I was thinking about the other way.
- the process can bind the master thread if we want(by default we don't have
to)
- Release the binding of the threads at fork(by bind to all cores), so the
child thread can freely move around using whatever cores they like
----------------------------------------------------------------
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