Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenlib/BLI_task.hh
| Show All 25 Lines | |||||
| /* TBB includes Windows.h which will define min/max macros causing issues | /* TBB includes Windows.h which will define min/max macros causing issues | ||||
| * when we try to use std::min and std::max later on. */ | * when we try to use std::min and std::max later on. */ | ||||
| # define NOMINMAX | # define NOMINMAX | ||||
| # define TBB_MIN_MAX_CLEANUP | # define TBB_MIN_MAX_CLEANUP | ||||
| # endif | # endif | ||||
| # include <tbb/blocked_range.h> | # include <tbb/blocked_range.h> | ||||
| # include <tbb/parallel_for.h> | # include <tbb/parallel_for.h> | ||||
| # include <tbb/parallel_for_each.h> | # include <tbb/parallel_for_each.h> | ||||
| # include <tbb/parallel_invoke.h> | |||||
| # include <tbb/parallel_reduce.h> | # include <tbb/parallel_reduce.h> | ||||
| # include <tbb/task_arena.h> | # include <tbb/task_arena.h> | ||||
| # ifdef WIN32 | # ifdef WIN32 | ||||
| /* We cannot keep this defined, since other parts of the code deal with this on their own, leading | /* We cannot keep this defined, since other parts of the code deal with this on their own, leading | ||||
| * to multiple define warnings unless we un-define this, however we can only undefine this if we | * to multiple define warnings unless we un-define this, however we can only undefine this if we | ||||
| * were the ones that made the definition earlier. */ | * were the ones that made the definition earlier. */ | ||||
| # ifdef TBB_MIN_MAX_CLEANUP | # ifdef TBB_MIN_MAX_CLEANUP | ||||
| # undef NOMINMAX | # undef NOMINMAX | ||||
| Show All 30 Lines | tbb::parallel_for(tbb::blocked_range<int64_t>(range.first(), range.one_after_last(), grain_size), | ||||
| function(IndexRange(subrange.begin(), subrange.size())); | function(IndexRange(subrange.begin(), subrange.size())); | ||||
| }); | }); | ||||
| #else | #else | ||||
| UNUSED_VARS(grain_size); | UNUSED_VARS(grain_size); | ||||
| function(range); | function(range); | ||||
| #endif | #endif | ||||
| } | } | ||||
| template<typename F1, typename F2> void parallel_invoke(F1 &&f1, F2 &&f2) | |||||
| { | |||||
| #ifdef WITH_TBB | |||||
| tbb::parallel_invoke(std::forward<F1>(f1), std::forward<F2>(f2)); | |||||
| #else | |||||
| f1(); | |||||
| f2(); | |||||
| #endif | |||||
| } | |||||
| template<typename Value, typename Function, typename Reduction> | template<typename Value, typename Function, typename Reduction> | ||||
| Value parallel_reduce(IndexRange range, | Value parallel_reduce(IndexRange range, | ||||
| int64_t grain_size, | int64_t grain_size, | ||||
| const Value &identity, | const Value &identity, | ||||
| const Function &function, | const Function &function, | ||||
| const Reduction &reduction) | const Reduction &reduction) | ||||
| { | { | ||||
| #ifdef WITH_TBB | #ifdef WITH_TBB | ||||
| Show All 24 Lines | |||||