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-08 14:08:18 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-01-09 18:09:33 +0300
commitc4e42d70a4949352f1233574cfc2da30c097439d (patch)
tree01dd50d86510f84ec90a8d9fcf9e680599ec9ef0 /source/blender/blenlib/BLI_task.h
parent3144f0573a24a29363995d0fefeb8eeba1320f24 (diff)
Task scheduler: Add minimum number of iterations per thread in parallel range
The idea is to support following: allow doing parallel for on a small range, each iteration of which takes lots of compute power, but limit such range to a subset of threads. For example, on a machine with 44 threads we can occupy 4 threads to handle range of 64 elements, 16 elements per thread, where each block of 16 elements is very complex to compute. The idea should be to use this setting instead of global use_threading flag, which is only based on size of array. Proper use of the new flag will improve threadability. This commit only contains internal task scheduler changes, this setting is not used yet by any areas.
Diffstat (limited to 'source/blender/blenlib/BLI_task.h')
-rw-r--r--source/blender/blenlib/BLI_task.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_task.h b/source/blender/blenlib/BLI_task.h
index b4c374d3fe7..0f78d2f4361 100644
--- a/source/blender/blenlib/BLI_task.h
+++ b/source/blender/blenlib/BLI_task.h
@@ -167,6 +167,17 @@ typedef struct ParallelRangeSettings {
* processed.
*/
TaskParallelRangeFuncFinalize func_finalize;
+ /* Minimum allowed number of range iterators to be handled by a single
+ * thread. This allows to achieve following:
+ * - Reduce amount of threading overhead.
+ * - Partially occupy thread pool with ranges which are computationally
+ * expensive, but which are smaller than amount of available threads.
+ * For example, it's possible to multi-thread [0 .. 64] range into 4
+ * thread which will be doing 16 iterators each.
+ * This is a preferred way to tell scheduler when to start threading than
+ * having a global use_threading switch based on just range size.
+ */
+ int min_iter_per_thread;
} ParallelRangeSettings;
BLI_INLINE void BLI_parallel_range_settings_defaults(
@@ -203,6 +214,11 @@ BLI_INLINE void BLI_parallel_range_settings_defaults(
memset(settings, 0, sizeof(*settings));
settings->use_threading = true;
settings->scheduling_mode = TASK_SCHEDULING_STATIC;
+ /* NOTE: Current value mimics old behavior, but it's not ideal by any
+ * means. Would be cool to find a common value which will work good enough
+ * for both static and dynamic scheduling.
+ */
+ settings->min_iter_per_thread = 1;
}
#ifdef __cplusplus