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-05 18:33:13 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-09 18:09:33 +0300
commitd2708b0f73d5f0e0a40b36da21c6a0d15405e739 (patch)
tree53d699a0a7701dbe009234633a38065e6f474cdf /source/blender/blenlib/BLI_task.h
parentf5d64b59f5152114cfa25a2b7433ed25204cb149 (diff)
Task scheduler: Get rid of extended version of parallel range callback
Wrap all arguments into TLS type of argument. Avoids some branching and also makes it easier to extend things in the future.
Diffstat (limited to 'source/blender/blenlib/BLI_task.h')
-rw-r--r--source/blender/blenlib/BLI_task.h20
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index ccfa2b6e2e7..acfdd3729c1 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -116,15 +116,27 @@ void BLI_task_pool_delayed_push_begin(TaskPool *pool, int thread_id);
void BLI_task_pool_delayed_push_end(TaskPool *pool, int thread_id);
/* Parallel for routines */
-typedef void (*TaskParallelRangeFunc)(void *userdata, const int iter);
-typedef void (*TaskParallelRangeFuncEx)(void *userdata, void *userdata_chunk, const int iter, const int thread_id);
+
+/* Per-thread specific data passed to the callback. */
+typedef struct ParallelRangeTLS {
+ /* 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.
+ */
+ void *userdata_chunk;
+} ParallelRangeTLS;
+
+typedef void (*TaskParallelRangeFunc)(void *userdata,
+ const int iter,
+ const ParallelRangeTLS *tls);
typedef void (*TaskParallelRangeFuncFinalize)(void *userdata, void *userdata_chunk);
void BLI_task_parallel_range_ex(
int start, int stop,
void *userdata,
void *userdata_chunk,
const size_t userdata_chunk_size,
- TaskParallelRangeFuncEx func_ex,
+ TaskParallelRangeFunc func,
const bool use_threading,
const bool use_dynamic_scheduling);
void BLI_task_parallel_range(
@@ -138,7 +150,7 @@ void BLI_task_parallel_range_finalize(
void *userdata,
void *userdata_chunk,
const size_t userdata_chunk_size,
- TaskParallelRangeFuncEx func_ex,
+ TaskParallelRangeFunc func,
TaskParallelRangeFuncFinalize func_finalize,
const bool use_threading,
const bool use_dynamic_scheduling);