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:
authorBastien Montagne <b.mont29@gmail.com>2019-11-25 13:58:09 +0300
committerBastien Montagne <b.mont29@gmail.com>2019-11-25 13:58:09 +0300
commitf9028a3be1f77c01edca44a68894e2ba9d9cfb14 (patch)
treed6cbefef7d19c292af1a85d2b8853d83042e5667 /source/blender/blenlib/BLI_task.h
parent85cf56ecbc62dc8d77ba177d01b32065e63166cc (diff)
BLI_task: Add pooled threaded index range iterator.
This code allows to push a set of different operations all based on iterations over a range of indices, and then process them all at once over multiple threads. This commit also adds unit tests for both old un-pooled, and new pooled `task_parallel_range` family of functions, as well as some basic performances tests. This is mainly interesting for relatively low amount of individual tasks, as expected. E.g. performance tests on a 32 threads machine, for a set of 10 different tasks, shows following improvements when using pooled version instead of ten sequential calls to `BLI_task_parallel_range()`: | Num Items | Sequential | Pooled | Speed-up | | --------- | ---------- | ------- | -------- | | 10K | 365 us | 138 us | 2.5 x | | 100K | 877 us | 530 us | 1.66 x | | 1000K | 5521 us | 4625 us | 1.25 x | Differential Revision: https://developer.blender.org/D6189
Diffstat (limited to 'source/blender/blenlib/BLI_task.h')
-rw-r--r--source/blender/blenlib/BLI_task.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index 7ef5e518cc8..05c3d43a0de 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -196,9 +196,22 @@ void BLI_task_parallel_range(const int start,
const int stop,
void *userdata,
TaskParallelRangeFunc func,
- const TaskParallelSettings *settings);
-
-/* This data is shared between all tasks, its access needs thread lock or similar protection. */
+ TaskParallelSettings *settings);
+
+typedef struct TaskParallelRangePool TaskParallelRangePool;
+struct TaskParallelRangePool *BLI_task_parallel_range_pool_init(
+ const struct TaskParallelSettings *settings);
+void BLI_task_parallel_range_pool_push(struct TaskParallelRangePool *range_pool,
+ const int start,
+ const int stop,
+ void *userdata,
+ TaskParallelRangeFunc func,
+ const struct TaskParallelSettings *settings);
+void BLI_task_parallel_range_pool_work_and_wait(struct TaskParallelRangePool *range_pool);
+void BLI_task_parallel_range_pool_free(struct TaskParallelRangePool *range_pool);
+
+/* This data is shared between all tasks, its access needs thread lock or similar protection.
+ */
typedef struct TaskParallelIteratorStateShared {
/* Maximum amount of items to acquire at once. */
int chunk_size;