Fix Cycles unnecessary overhead cancelling finished task pool

This commit is contained in:
Brecht Van Lommel 2020-10-23 18:54:45 +02:00 committed by Howard Trickey
parent 594f47ecd2
commit b37c40a575
Notes: blender-bot 2023-05-03 10:14:48 +02:00
Referenced by issue #80736, Cycles CPU Preview Artifact
2 changed files with 12 additions and 7 deletions

View File

@ -24,7 +24,7 @@ CCL_NAMESPACE_BEGIN
/* Task Pool */
TaskPool::TaskPool() : start_time(time_dt()), num_tasks_handled(0)
TaskPool::TaskPool() : start_time(time_dt()), num_tasks_pushed(0)
{
}
@ -36,7 +36,7 @@ TaskPool::~TaskPool()
void TaskPool::push(TaskRunFunction &&task)
{
tbb_group.run(std::move(task));
num_tasks_handled++;
num_tasks_pushed++;
}
void TaskPool::wait_work(Summary *stats)
@ -45,14 +45,19 @@ void TaskPool::wait_work(Summary *stats)
if (stats != NULL) {
stats->time_total = time_dt() - start_time;
stats->num_tasks_handled = num_tasks_handled;
stats->num_tasks_handled = num_tasks_pushed;
}
num_tasks_pushed = 0;
}
void TaskPool::cancel()
{
tbb_group.cancel();
tbb_group.wait();
if (num_tasks_pushed > 0) {
tbb_group.cancel();
tbb_group.wait();
num_tasks_pushed = 0;
}
}
bool TaskPool::canceled()

View File

@ -71,8 +71,8 @@ class TaskPool {
/* Time time stamp of first task pushed. */
double start_time;
/* Number of all tasks handled by this pool. */
int num_tasks_handled;
/* Number of all tasks pushed to the pool. Cleared after wait_work() and cancel(). */
int num_tasks_pushed;
};
/* Task Scheduler