diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:09:22 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-08-31 03:09:22 +0400 |
commit | 6785874e7adf5ef15e7a28b134b2bd4e8b3a8988 (patch) | |
tree | 12adcc0c7313c9376919cf748f3310f02b67a9c7 /intern/cycles/util/util_task.h | |
parent | f477c0e535168b22509514e7421e6fc5ed5bf1ac (diff) |
Fix #36137: cycles render not using all GPU's when the number of GPU's is larger
than the number of CPU threads
Diffstat (limited to 'intern/cycles/util/util_task.h')
-rw-r--r-- | intern/cycles/util/util_task.h | 53 |
1 files changed, 49 insertions, 4 deletions
diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index 11829ab0ae0..22515e3e433 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -50,7 +50,7 @@ public: * pool, we can wait for all tasks to be done, or cancel them before they are * done. * - * The run callback that actually executes the task may be create like this: + * The run callback that actually executes the task may be created like this: * function_bind(&MyClass::task_execute, this, _1, _2) */ class TaskPool @@ -77,8 +77,8 @@ protected: thread_mutex num_mutex; thread_condition_variable num_cond; - volatile int num; - volatile bool do_cancel; + int num; + bool do_cancel; }; /* Task Scheduler @@ -109,7 +109,7 @@ protected: static thread_mutex mutex; static int users; static vector<thread*> threads; - static volatile bool do_exit; + static bool do_exit; static list<Entry> queue; static thread_mutex queue_mutex; @@ -122,6 +122,51 @@ protected: static void clear(TaskPool *pool); }; +/* Dedicated Task Pool + * + * Like a TaskPool, but will launch one dedicated thread to execute all tasks. + * + * The run callback that actually executes the task may be created like this: + * function_bind(&MyClass::task_execute, this, _1, _2) */ + +class DedicatedTaskPool +{ +public: + DedicatedTaskPool(); + ~DedicatedTaskPool(); + + void push(Task *task, bool front = false); + void push(const TaskRunFunction& run, bool front = false); + + void wait(); /* wait until all tasks are done */ + void cancel(); /* cancel all tasks, keep worker thread running */ + void stop(); /* stop worker thread */ + + bool cancelled(); /* for worker thread, test if cancelled */ + +protected: + void num_decrease(int done); + void num_increase(); + + void thread_run(); + bool thread_wait_pop(Task*& entry); + + void clear(); + + thread_mutex num_mutex; + thread_condition_variable num_cond; + + list<Task*> queue; + thread_mutex queue_mutex; + thread_condition_variable queue_cond; + + int num; + bool do_cancel; + bool do_exit; + + thread *worker_thread; +}; + CCL_NAMESPACE_END #endif |