7 #ifndef PXR_BASE_WORK_TBB_LOOPS_IMPL_H
8 #define PXR_BASE_WORK_TBB_LOOPS_IMPL_H
12 #include <tbb/blocked_range.h>
13 #include <tbb/parallel_for.h>
14 #include <tbb/parallel_for_each.h>
15 #include <tbb/task_group.h>
21 #define WORK_IMPL_HAS_PARALLEL_FOR_TBB_RANGE
29 template <
typename Fn>
33 class Work_ParallelForN_TBB
36 Work_ParallelForN_TBB(Fn &fn) : _fn(fn) { }
38 void operator()(
const tbb::blocked_range<size_t> &
r)
const {
44 std::forward<Fn>(_fn)(r.begin(), r.end());
53 tbb::task_group_context ctx(tbb::task_group_context::isolated);
55 Work_ParallelForN_TBB(callback),
61 template <
typename RangeType,
typename Fn>
65 tbb::task_group_context ctx(tbb::task_group_context::isolated);
71 template <
typename InputIterator,
typename Fn>
74 InputIterator
first, InputIterator
last, Fn &&fn)
76 tbb::task_group_context ctx(tbb::task_group_context::isolated);
77 tbb::parallel_for_each(first, last, std::forward<Fn>(fn), ctx);
82 #endif // PXR_BASE_WORK_TBB_LOOPS_IMPL_H
#define PXR_NAMESPACE_OPEN_SCOPE
void WorkImpl_ParallelForTBBRange(const RangeType &range, Fn &&callback)
void WorkImpl_ParallelForEach(InputIterator first, InputIterator last, Fn &&fn)
OIIO_UTIL_API void parallel_for(int32_t begin, int32_t end, function_view< void(int32_t)> task, paropt opt=0)
__hostdev__ uint64_t last(uint32_t i) const
#define PXR_NAMESPACE_CLOSE_SCOPE
PXR_NAMESPACE_OPEN_SCOPE void WorkImpl_ParallelForN(size_t n, Fn &&callback, size_t grainSize)