diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-08 01:00:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-11-08 01:00:49 +0400 |
commit | 204113b791a8eea6087de61199df1d5811055244 (patch) | |
tree | 16feb83be39dba028f83a233f367cfdb72c8f342 /intern | |
parent | b51908b913f318986a91c766980ed01010c5249a (diff) |
Fix #33107: cycles fixed threads 1 was still having two cores do work,
because main thread works as well.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/device/device.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/device/device.h | 2 | ||||
-rw-r--r-- | intern/cycles/device/device_cpu.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/device/device_intern.h | 2 | ||||
-rw-r--r-- | intern/cycles/render/session.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/util/util_task.cpp | 10 | ||||
-rw-r--r-- | intern/cycles/util/util_task.h | 5 |
8 files changed, 25 insertions, 13 deletions
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index c63f72c68c6..024cb1685d0 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -379,7 +379,10 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use params.start_resolution = get_int(cscene, "preview_start_resolution"); /* other parameters */ - params.threads = b_scene.render().threads(); + if(b_scene.render().threads_mode() == BL::RenderSettings::threads_mode_FIXED) + params.threads = b_scene.render().threads(); + else + params.threads = 0; params.cancel_timeout = get_float(cscene, "debug_cancel_timeout"); params.reset_timeout = get_float(cscene, "debug_reset_timeout"); diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 550da2982a3..c6a2c678bac 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -78,13 +78,13 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w glDisable(GL_BLEND); } -Device *Device::create(DeviceInfo& info, Stats &stats, bool background, int threads) +Device *Device::create(DeviceInfo& info, Stats &stats, bool background) { Device *device; switch(info.type) { case DEVICE_CPU: - device = device_cpu_create(info, stats, threads); + device = device_cpu_create(info, stats); break; #ifdef WITH_CUDA case DEVICE_CUDA: diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index 95da0a89833..9840687b76a 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -134,7 +134,7 @@ public: virtual int device_number(Device *sub_device) { return 0; } /* static */ - static Device *create(DeviceInfo& info, Stats &stats, bool background = true, int threads = 0); + static Device *create(DeviceInfo& info, Stats &stats, bool background = true); static DeviceType type_from_string(const char *name); static string string_from_type(DeviceType type); diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index 519c458ffdf..bc280616615 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -45,7 +45,7 @@ public: TaskPool task_pool; KernelGlobals *kg; - CPUDevice(Stats &stats, int threads_num) : Device(stats) + CPUDevice(Stats &stats) : Device(stats) { kg = kernel_globals_create(); @@ -274,7 +274,7 @@ public: /* split task into smaller ones, more than number of threads for uneven * workloads where some parts of the image render slower than others */ list<DeviceTask> tasks; - task.split(tasks, TaskScheduler::num_threads()+1); + task.split(tasks, TaskScheduler::num_threads()); foreach(DeviceTask& task, tasks) task_pool.push(new CPUDeviceTask(this, task)); @@ -291,9 +291,9 @@ public: } }; -Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads) +Device *device_cpu_create(DeviceInfo& info, Stats &stats) { - return new CPUDevice(stats, threads); + return new CPUDevice(stats); } void device_cpu_info(vector<DeviceInfo>& devices) diff --git a/intern/cycles/device/device_intern.h b/intern/cycles/device/device_intern.h index 02fbac6860e..b49ebba3e8b 100644 --- a/intern/cycles/device/device_intern.h +++ b/intern/cycles/device/device_intern.h @@ -23,7 +23,7 @@ CCL_NAMESPACE_BEGIN class Device; -Device *device_cpu_create(DeviceInfo& info, Stats &stats, int threads); +Device *device_cpu_create(DeviceInfo& info, Stats &stats); Device *device_opencl_create(DeviceInfo& info, Stats &stats, bool background); Device *device_cuda_create(DeviceInfo& info, Stats &stats, bool background); Device *device_network_create(DeviceInfo& info, Stats &stats, const char *address); diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 7303cb52ad8..024af8dede8 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -49,7 +49,7 @@ Session::Session(const SessionParams& params_) TaskScheduler::init(params.threads); - device = Device::create(params.device, stats, params.background, params.threads); + device = Device::create(params.device, stats, params.background); if(params.background) { buffers = NULL; 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: |