Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-08 01:00:49 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-11-08 01:00:49 +0400
commit204113b791a8eea6087de61199df1d5811055244 (patch)
tree16feb83be39dba028f83a233f367cfdb72c8f342 /intern/cycles/util
parentb51908b913f318986a91c766980ed01010c5249a (diff)
Fix #33107: cycles fixed threads 1 was still having two cores do work,
because main thread works as well.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_task.cpp10
-rw-r--r--intern/cycles/util/util_task.h5
2 files changed, 12 insertions, 3 deletions
diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp
index ea0abd6f54f..8c4ec312256 100644
--- a/intern/cycles/util/util_task.cpp
+++ b/intern/cycles/util/util_task.cpp
@@ -168,10 +168,16 @@ void TaskScheduler::init(int num_threads)
if(users == 0) {
do_exit = false;
- /* launch threads that will be waiting for work */
- if(num_threads == 0)
+ if(num_threads == 0) {
+ /* automatic number of threads will be main thread + num cores */
num_threads = system_cpu_thread_count();
+ }
+ else {
+ /* main thread will also work, for fixed threads we count it too */
+ num_threads -= 1;
+ }
+ /* launch threads that will be waiting for work */
threads.resize(num_threads);
thread_level.resize(num_threads);
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h
index a2f284479c7..b795ca7524b 100644
--- a/intern/cycles/util/util_task.h
+++ b/intern/cycles/util/util_task.h
@@ -94,7 +94,10 @@ public:
static void init(int num_threads = 0);
static void exit();
- static int num_threads() { return threads.size(); }
+ /* number of threads that can work on tasks, main thread counts too */
+ static int num_threads() { return threads.size() + 1; }
+
+ /* test if any session is using the scheduler */
static bool active() { return users != 0; }
protected: