diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-12-27 21:01:19 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-12-27 21:12:59 +0300 |
commit | 826d7adde79216d271b78059c05abd10b7559899 (patch) | |
tree | 5d8b334bf5603208e12b579e5a6cd1314d29cfdd /intern/cycles/util/util_thread.cpp | |
parent | de14ddf3a141cb0e2baff00b06dc7d86d3088916 (diff) |
Fix T59874: Cycles CPU 25% load only during rendering
The issue was introduced by a Threadripper2 commit back in
ce927e15e0e3. This boils down to threads inheriting affinity
from the parent thread. It is a question how this slipped
through the review (we definitely run benchmark round).
Quick fix could have been to always set CPU group affinity
in Cycles, and it would work for Windows. On other platforms
we did not have CPU groups API finished.
Ended up making Cycles aware of NUMA topology, so now we
bound threads to a specific NUMA node. This required adding
an external dependency to Cycles, but made some code there
shorter.
Diffstat (limited to 'intern/cycles/util/util_thread.cpp')
-rw-r--r-- | intern/cycles/util/util_thread.cpp | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/intern/cycles/util/util_thread.cpp b/intern/cycles/util/util_thread.cpp index 37d8bdbd4b0..4d30e3f564f 100644 --- a/intern/cycles/util/util_thread.cpp +++ b/intern/cycles/util/util_thread.cpp @@ -21,10 +21,10 @@ CCL_NAMESPACE_BEGIN -thread::thread(function<void()> run_cb, int group) +thread::thread(function<void()> run_cb, int node) : run_cb_(run_cb), joined_(false), - group_(group) + node_(node) { thread_ = std::thread(&thread::run, this); } @@ -39,19 +39,8 @@ thread::~thread() void *thread::run(void *arg) { thread *self = (thread*)(arg); - if(self->group_ != -1) { -#ifdef _WIN32 - HANDLE thread_handle = GetCurrentThread(); - GROUP_AFFINITY group_affinity = { 0 }; - int num_threads = system_cpu_group_thread_count(self->group_); - group_affinity.Group = self->group_; - group_affinity.Mask = (num_threads == 64) - ? -1 - : (1ull << num_threads) - 1; - if(SetThreadGroupAffinity(thread_handle, &group_affinity, NULL) == 0) { - fprintf(stderr, "Error setting thread affinity.\n"); - } -#endif + if (self->node_ != -1) { + system_cpu_run_thread_on_node(self->node_); } self->run_cb_(); return NULL; |