[Bf-blender-cvs] [af83535dd0f] blender-v2.79a-release: Task scheduler: Clarify why do we need an atomic add of 0
Sergey Sharybin
noreply at git.blender.org
Mon Jan 22 12:57:25 CET 2018
Commit: af83535dd0f2032c72abd62254f566da2db9f65b
Author: Sergey Sharybin
Date: Mon Jan 22 12:56:35 2018 +0100
Branches: blender-v2.79a-release
https://developer.blender.org/rBaf83535dd0f2032c72abd62254f566da2db9f65b
Task scheduler: Clarify why do we need an atomic add of 0
===================================================================
M source/blender/blenlib/intern/task.c
===================================================================
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index e050f3148b8..da632e92e08 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -1124,6 +1124,9 @@ static void task_parallel_range_ex(
}
num_tasks = min_ii(num_tasks, (stop - start) / state.chunk_size);
+
+ /* NOTE: This way we are adding a memory barrier and ensure all worker
+ * threads can read and modify the value, without any locks. */
atomic_fetch_and_add_uint32((uint32_t *)(&state.iter), 0);
if (use_userdata_chunk) {
More information about the Bf-blender-cvs
mailing list