[Bf-blender-cvs] [361702f2395] master: Fix T94310: Blender doesn't support with 128 threads well in Win11

Jagannadhan Ravi noreply at git.blender.org
Fri Jan 7 11:38:36 CET 2022


Commit: 361702f239528803260ba966d4174b8601e90a53
Author: Jagannadhan Ravi
Date:   Fri Jan 7 11:31:02 2022 +0100
Branches: master
https://developer.blender.org/rB361702f239528803260ba966d4174b8601e90a53

Fix T94310: Blender doesn't support with 128 threads well in Win11

Query TBB for the maximum allowed concurrency, which is free from a bug
in own concurrency detection code. One thing to keep in mind is that now
Cycles is limited by the number of threads in the TBB areana from which
Session is created. This isn't a problem for Blender since we do not limit
arena on Blender side. Could be something to watch out for in other Cycles
integrations.

Differential Revision: https://developer.blender.org/D13658

===================================================================

M	intern/cycles/device/device.cpp
M	intern/cycles/util/task.cpp

===================================================================

diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp
index 2b067d57158..d3de6c54a17 100644
--- a/intern/cycles/device/device.cpp
+++ b/intern/cycles/device/device.cpp
@@ -37,6 +37,7 @@
 #include "util/math.h"
 #include "util/string.h"
 #include "util/system.h"
+#include "util/task.h"
 #include "util/time.h"
 #include "util/types.h"
 #include "util/vector.h"
@@ -333,7 +334,7 @@ DeviceInfo Device::get_multi_device(const vector<DeviceInfo> &subdevices,
     /* Ensure CPU device does not slow down GPU. */
     if (device.type == DEVICE_CPU && subdevices.size() > 1) {
       if (background) {
-        int orig_cpu_threads = (threads) ? threads : system_cpu_thread_count();
+        int orig_cpu_threads = (threads) ? threads : TaskScheduler::num_threads();
         int cpu_threads = max(orig_cpu_threads - (subdevices.size() - 1), 0);
 
         VLOG(1) << "CPU render threads reduced from " << orig_cpu_threads << " to " << cpu_threads
diff --git a/intern/cycles/util/task.cpp b/intern/cycles/util/task.cpp
index ce61bf8d6c4..eeccbaf1c44 100644
--- a/intern/cycles/util/task.cpp
+++ b/intern/cycles/util/task.cpp
@@ -89,7 +89,7 @@ void TaskScheduler::init(int num_threads)
     active_num_threads = num_threads;
   }
   else {
-    active_num_threads = system_cpu_thread_count();
+    active_num_threads = tbb::this_task_arena::max_concurrency();
   }
 }



More information about the Bf-blender-cvs mailing list