diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-20 11:59:12 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-20 12:08:05 +0300 |
commit | 5c81d3bd4691214164a7f071d239ef6c84dba8dc (patch) | |
tree | cbab752ca58da40b45c15540707a2b0a22d769da /source/blender/blenlib/BLI_task.hh | |
parent | 7a239812ca55153fc9751b6a87bc5c4deb76456b (diff) |
Geometry Nodes: improve evaluator with lazy threading
In large node setup the threading overhead was sometimes very significant.
That's especially true when most nodes do very little work.
This commit improves the scheduling by not using multi-threading in many
cases unless it's likely that it will be worth it. For more details see the comments
in `BLI_lazy_threading.hh`.
Differential Revision: https://developer.blender.org/D15976
Diffstat (limited to 'source/blender/blenlib/BLI_task.hh')
-rw-r--r-- | source/blender/blenlib/BLI_task.hh | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_task.hh b/source/blender/blenlib/BLI_task.hh index 33a781d3749..9f9a57be634 100644 --- a/source/blender/blenlib/BLI_task.hh +++ b/source/blender/blenlib/BLI_task.hh @@ -31,6 +31,7 @@ #endif #include "BLI_index_range.hh" +#include "BLI_lazy_threading.hh" #include "BLI_utildefines.h" namespace blender::threading { @@ -56,6 +57,7 @@ void parallel_for(IndexRange range, int64_t grain_size, const Function &function #ifdef WITH_TBB /* Invoking tbb for small workloads has a large overhead. */ if (range.size() >= grain_size) { + lazy_threading::send_hint(); tbb::parallel_for( tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size), [&](const tbb::blocked_range<int64_t> &subrange) { @@ -78,6 +80,7 @@ Value parallel_reduce(IndexRange range, { #ifdef WITH_TBB if (range.size() >= grain_size) { + lazy_threading::send_hint(); return tbb::parallel_reduce( tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size), identity, @@ -114,6 +117,7 @@ template<typename... Functions> void parallel_invoke(const bool use_threading, Functions &&...functions) { if (use_threading) { + lazy_threading::send_hint(); parallel_invoke(std::forward<Functions>(functions)...); } else { |