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:
-rw-r--r--source/blender/blenlib/BLI_task.hh15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh
index da7309837c8..84d5cd39bb4 100644
--- a/source/blender/blenlib/BLI_task.hh
+++ b/source/blender/blenlib/BLI_task.hh
@@ -67,14 +67,19 @@ void parallel_for(IndexRange range, int64_t grain_size, const Function &function
return;
}
#ifdef WITH_TBB
- tbb::parallel_for(tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size),
- [&](const tbb::blocked_range<int64_t> &subrange) {
- function(IndexRange(subrange.begin(), subrange.size()));
- });
+ /* Invoking tbb for small workloads has a large overhead. */
+ if (range.size() >= grain_size) {
+ tbb::parallel_for(
+ tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size),
+ [&](const tbb::blocked_range<int64_t> &subrange) {
+ function(IndexRange(subrange.begin(), subrange.size()));
+ });
+ return;
+ }
#else
UNUSED_VARS(grain_size);
- function(range);
#endif
+ function(range);
}
template<typename Value, typename Function, typename Reduction>