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 <montagne29@wanadoo.fr>2015-12-30 22:39:56 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-12-30 22:39:56 +0300
commit511e3c5d9d503b47cd5fb6fe48abeafde9fbff2d (patch)
tree5777460ffb9b9178d9d46c9db74c5c6d8c60b5e0 /source/blender/blenlib/intern/task.c
parentd9bb4a200c6e41baaa399993e27944f40c14bca3 (diff)
BLI_task: change BLI_task_parallel_range_ex() to just take a bool whether to use threading or not, instead of threshold.
From recent experience, turns out we often do want to use something else than basic range of parallelized forloop as control parameter over threads usage, so now BLI func only takes a boolean, and caller defines best check for its own case.
Diffstat (limited to 'source/blender/blenlib/intern/task.c')
-rw-r--r--source/blender/blenlib/intern/task.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c
index 104ebcec26b..d3b11d8e6d0 100644
--- a/source/blender/blenlib/intern/task.c
+++ b/source/blender/blenlib/intern/task.c
@@ -643,8 +643,8 @@ static void parallel_range_func(
* (similar to OpenMP's firstprivate).
* \param userdata_chunk_size Memory size of \a userdata_chunk.
* \param func Callback function.
- * \param range_threshold Minimum size of processed range to start using tasks
- * (below this, loop is done in main thread only).
+ * \param use_threading If \a true, actually split-execute loop in threads, else just do a sequential forloop
+ * (allows caller to use any kind of test to switch on parallelization or not).
* \param use_dynamic_scheduling If \a true, the whole range is divided in a lot of small chunks (of size 32 currently),
* otherwise whole range is split in a few big chunks (num_threads * 2 chunks currently).
*/
@@ -654,7 +654,7 @@ void BLI_task_parallel_range_ex(
void *userdata_chunk,
const size_t userdata_chunk_size,
TaskParallelRangeFunc func,
- const int range_threshold,
+ const bool use_threading,
const bool use_dynamic_scheduling)
{
TaskScheduler *task_scheduler;
@@ -667,7 +667,7 @@ void BLI_task_parallel_range_ex(
/* If it's not enough data to be crunched, don't bother with tasks at all,
* do everything from the main thread.
*/
- if (stop - start < range_threshold) {
+ if (!use_threading) {
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
void *userdata_chunk_local = NULL;
@@ -733,7 +733,7 @@ void BLI_task_parallel_range(
void *userdata,
TaskParallelRangeFunc func)
{
- BLI_task_parallel_range_ex(start, stop, userdata, NULL, 0, func, 64, false);
+ BLI_task_parallel_range_ex(start, stop, userdata, NULL, 0, func, (stop - start) > 64, false);
}
#undef MALLOCA