[Bf-blender-cvs] [83a6bbb09ab] temp-tbb-task-scheduler: Tasks: don't pass thread_id always, instead go through accessor

Brecht Van Lommel noreply at git.blender.org
Tue Nov 5 15:11:00 CET 2019


Commit: 83a6bbb09ab5c592af521c56f595bd742b39a713
Author: Brecht Van Lommel
Date:   Sat Oct 12 17:11:36 2019 +0200
Branches: temp-tbb-task-scheduler
https://developer.blender.org/rB83a6bbb09ab5c592af521c56f595bd742b39a713

Tasks: don't pass thread_id always, instead go through accessor

We should move away from using thread IDs and instead store any thread local
data in the TaskParallelTLS. Getting the thread ID will also be more expensive
with TBB and is not so well defined.

===================================================================

M	source/blender/blenkernel/intern/editmesh_tangent.c
M	source/blender/blenkernel/intern/mesh_evaluate.c
M	source/blender/blenkernel/intern/mesh_tangent.c
M	source/blender/blenkernel/intern/ocean.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_distribute.c
M	source/blender/blenlib/BLI_task.h
M	source/blender/blenlib/intern/task_iterator.c
M	source/blender/blenlib/intern/task_pool.cc
M	source/blender/blenlib/intern/task_range.cc
M	source/blender/depsgraph/intern/eval/deg_eval.cc
M	source/blender/draw/intern/draw_cache_extract_mesh.c
M	source/blender/editors/mesh/editmesh_undo.c
M	source/blender/editors/physics/particle_edit.c
M	source/blender/editors/render/render_opengl.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/space_clip/clip_editor.c
M	source/blender/editors/space_clip/clip_ops.c
M	source/blender/editors/space_file/filelist.c
M	source/blender/imbuf/intern/imageprocess.c
M	tests/gtests/blenlib/BLI_linklist_lockfree_test.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 377acb7882a..71e60b4566d 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -251,9 +251,7 @@ finally:
   pRes[3] = fSign;
 }
 
-static void emDM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool),
-                                           void *taskdata,
-                                           int UNUSED(threadid))
+static void emDM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   struct SGLSLEditMeshToTangent *mesh2tangent = taskdata;
   /* new computation method */
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.c b/source/blender/blenkernel/intern/mesh_evaluate.c
index b16bcf0dbe8..0a9e499d389 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.c
+++ b/source/blender/blenkernel/intern/mesh_evaluate.c
@@ -1299,7 +1299,7 @@ static void loop_split_worker_do(LoopSplitTaskDataCommon *common_data,
   }
 }
 
-static void loop_split_worker(TaskPool *__restrict pool, void *taskdata, int UNUSED(threadid))
+static void loop_split_worker(TaskPool *__restrict pool, void *taskdata)
 {
   LoopSplitTaskDataCommon *common_data = BLI_task_pool_userdata(pool);
   LoopSplitTaskData *data = taskdata;
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index 9e0f92377e8..ab8dfdefabd 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -452,9 +452,7 @@ finally:
   pRes[3] = fSign;
 }
 
-static void DM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool),
-                                         void *taskdata,
-                                         int UNUSED(threadid))
+static void DM_calc_loop_tangents_thread(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   struct SGLSLMeshToTangent *mesh2tangent = taskdata;
   /* new computation method */
diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c
index 63bbf58481f..85c37486538 100644
--- a/source/blender/blenkernel/intern/ocean.c
+++ b/source/blender/blenkernel/intern/ocean.c
@@ -540,9 +540,7 @@ static void ocean_compute_htilda(void *__restrict userdata,
   }
 }
 
-static void ocean_compute_displacement_y(TaskPool *__restrict pool,
-                                         void *UNUSED(taskdata),
-                                         int UNUSED(threadid))
+static void ocean_compute_displacement_y(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -550,9 +548,7 @@ static void ocean_compute_displacement_y(TaskPool *__restrict pool,
   fftw_execute(o->_disp_y_plan);
 }
 
-static void ocean_compute_displacement_x(TaskPool *__restrict pool,
-                                         void *UNUSED(taskdata),
-                                         int UNUSED(threadid))
+static void ocean_compute_displacement_x(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -581,9 +577,7 @@ static void ocean_compute_displacement_x(TaskPool *__restrict pool,
   fftw_execute(o->_disp_x_plan);
 }
 
-static void ocean_compute_displacement_z(TaskPool *__restrict pool,
-                                         void *UNUSED(taskdata),
-                                         int UNUSED(threadid))
+static void ocean_compute_displacement_z(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -612,9 +606,7 @@ static void ocean_compute_displacement_z(TaskPool *__restrict pool,
   fftw_execute(o->_disp_z_plan);
 }
 
-static void ocean_compute_jacobian_jxx(TaskPool *__restrict pool,
-                                       void *UNUSED(taskdata),
-                                       int UNUSED(threadid))
+static void ocean_compute_jacobian_jxx(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -647,9 +639,7 @@ static void ocean_compute_jacobian_jxx(TaskPool *__restrict pool,
   }
 }
 
-static void ocean_compute_jacobian_jzz(TaskPool *__restrict pool,
-                                       void *UNUSED(taskdata),
-                                       int UNUSED(threadid))
+static void ocean_compute_jacobian_jzz(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -682,9 +672,7 @@ static void ocean_compute_jacobian_jzz(TaskPool *__restrict pool,
   }
 }
 
-static void ocean_compute_jacobian_jxz(TaskPool *__restrict pool,
-                                       void *UNUSED(taskdata),
-                                       int UNUSED(threadid))
+static void ocean_compute_jacobian_jxz(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -711,9 +699,7 @@ static void ocean_compute_jacobian_jxz(TaskPool *__restrict pool,
   fftw_execute(o->_Jxz_plan);
 }
 
-static void ocean_compute_normal_x(TaskPool *__restrict pool,
-                                   void *UNUSED(taskdata),
-                                   int UNUSED(threadid))
+static void ocean_compute_normal_x(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
@@ -732,9 +718,7 @@ static void ocean_compute_normal_x(TaskPool *__restrict pool,
   fftw_execute(o->_N_x_plan);
 }
 
-static void ocean_compute_normal_z(TaskPool *__restrict pool,
-                                   void *UNUSED(taskdata),
-                                   int UNUSED(threadid))
+static void ocean_compute_normal_z(TaskPool *__restrict pool, void *UNUSED(taskdata))
 {
   OceanSimulateData *osd = BLI_task_pool_userdata(pool);
   const Ocean *o = osd->o;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 5b08baae2c3..337f557b409 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -2735,9 +2735,7 @@ static void psys_thread_create_path(ParticleTask *task,
   }
 }
 
-static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool),
-                                  void *taskdata,
-                                  int UNUSED(threadid))
+static void exec_child_path_cache(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   ParticleTask *task = taskdata;
   ParticleThreadContext *ctx = task->ctx;
diff --git a/source/blender/blenkernel/intern/particle_distribute.c b/source/blender/blenkernel/intern/particle_distribute.c
index 493c7ddaf36..9cb32ac13c3 100644
--- a/source/blender/blenkernel/intern/particle_distribute.c
+++ b/source/blender/blenkernel/intern/particle_distribute.c
@@ -773,9 +773,7 @@ static void distribute_children_exec(ParticleTask *thread, ChildParticle *cpa, i
   }
 }
 
-static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool),
-                                   void *taskdata,
-                                   int UNUSED(threadid))
+static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   ParticleTask *task = taskdata;
   ParticleSystem *psys = task->ctx->sim.psys;
@@ -804,9 +802,7 @@ static void exec_distribute_parent(TaskPool *__restrict UNUSED(pool),
   }
 }
 
-static void exec_distribute_child(TaskPool *__restrict UNUSED(pool),
-                                  void *taskdata,
-                                  int UNUSED(threadid))
+static void exec_distribute_child(TaskPool *__restrict UNUSED(pool), void *taskdata)
 {
   ParticleTask *task = taskdata;
   ParticleSystem *psys = task->ctx->sim.psys;
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index 0ed4eaec214..e65d2e412cc 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -76,8 +76,8 @@ typedef enum TaskPriority {
 } TaskPriority;
 
 typedef struct TaskPool TaskPool;
-typedef void (*TaskRunFunction)(TaskPool *__restrict pool, void *taskdata, int threadid);
-typedef void (*TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata, int threadid);
+typedef void (*TaskRunFunction)(TaskPool *__restrict pool, void *taskdata);
+typedef void (*TaskFreeFunction)(TaskPool *__restrict pool, void *taskdata);
 
 TaskPool *BLI_task_pool_create(TaskScheduler *scheduler, void *userdata, TaskPriority priority);
 TaskPool *BLI_task_pool_create_background(TaskScheduler *scheduler,
@@ -114,8 +114,6 @@ ThreadMutex *BLI_task_pool_user_mutex(TaskPool *pool);
 
 /* Per-thread specific data passed to the callback. */
 typedef struct TaskParallelTLS {
-  /* Identifier of the thread who this data belongs to. */
-  int thread_id;
   /* Copy of user-specifier chunk, which is copied from original chunk to all
    * worker threads. This is similar to OpenMP's firstprivate.
    */
@@ -230,6 +228,10 @@ BLI_INLINE void BLI_parallel_range_settings_defaults(TaskParallelSettings *setti
   settings->min_iter_per_thread = 0;
 }
 
+/* Don't use this, store any thread specific data in tls->userdata_chunk instead.
+ * Ony here for code to be removed. */
+int BLI_task_parallel_thread_id(const TaskParallelTLS *tls);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenlib/intern/task_iterator.c b/source/blender/blenlib/intern/task_iterator.c
index 7d9ea048543..628c2b94c8c 100644
--- a/source/blender/blenlib/intern/task_iterator.c
+++ b/source/blender/blenlib/intern/task_iterator.c
@@ -100,11 +100,9 @@ typedef struct TaskParallelIteratorState {
 } TaskParallelIteratorState;
 
 static void parallel_iterator_func_do(TaskParallelIteratorState *__restrict state,
-                                      void *userdata_chunk,
-                                      int threadid)
+                                      void *userdata_chunk)
 {
   TaskParallelTLS tls = {
-

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list