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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-01-09 20:10:47 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-09 20:10:47 +0300
commit5fe87a0a8c7d9be3b913d9e8e0decb314cf5301d (patch)
treef9670a214819fe6ae32136b3e7f72055836ba2cb /source/blender/blenlib/intern/task.c
parent4a3b303bb03364523a782043e0888d608a3eb6d3 (diff)
Task scheduler: Use single thread branch when range fits into single chunk
Diffstat (limited to 'source/blender/blenlib/intern/task.c')
-rw-r--r--source/blender/blenlib/intern/task.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index c82d2298a36..29daac1ae48 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -1097,7 +1097,6 @@ void BLI_task_parallel_range(const int start, const int stop,
}
task_scheduler = BLI_task_scheduler_get();
- task_pool = BLI_task_pool_create_suspended(task_scheduler, &state);
num_threads = BLI_task_scheduler_num_threads(task_scheduler);
/* The idea here is to prevent creating task for each of the loop iterations
@@ -1126,9 +1125,15 @@ void BLI_task_parallel_range(const int start, const int stop,
num_tasks = min_ii(num_tasks,
max_ii(1, (stop - start) / state.chunk_size));
- /* TODO(sergey): If number of tasks happened to be 1, use single threaded
- * path.
- */
+ if (num_tasks == 1) {
+ palallel_range_single_thread(start, stop,
+ userdata,
+ func,
+ settings);
+ return;
+ }
+
+ task_pool = BLI_task_pool_create_suspended(task_scheduler, &state);
/* NOTE: This way we are adding a memory barrier and ensure all worker
* threads can read and modify the value, without any locks. */