24 #ifndef PXR_BASE_WORK_LOOPS_H
25 #define PXR_BASE_WORK_LOOPS_H
32 #include <tbb/blocked_range.h>
33 #include <tbb/parallel_for.h>
34 #include <tbb/parallel_for_each.h>
35 #include <tbb/task_group.h>
55 std::forward<Fn>(fn)(0, n);
73 template <
typename Fn>
83 class Work_ParallelForN_TBB
86 Work_ParallelForN_TBB(Fn &fn) : _fn(fn) { }
88 void operator()(
const tbb::blocked_range<size_t> &
r)
const {
94 std::forward<Fn>(_fn)(r.begin(), r.end());
103 tbb::task_group_context ctx(tbb::task_group_context::isolated);
105 Work_ParallelForN_TBB(callback),
127 template <
typename Fn>
147 template <
typename InputIterator,
typename Fn>
150 InputIterator
first, InputIterator
last, Fn &&fn)
152 tbb::task_group_context ctx(tbb::task_group_context::isolated);
158 #endif // PXR_BASE_WORK_LOOPS_H
void parallel_for(int64_t start, int64_t end, std::function< void(int64_t index)> &&task, parallel_options opt=parallel_options(0, Split_Y, 1))
PXR_NAMESPACE_OPEN_SCOPE void WorkSerialForN(size_t n, Fn &&fn)
void WorkParallelForN(size_t n, Fn &&callback, size_t grainSize)
UnaryFunction parallel_for_each(InputIt first, InputIt last, UnaryFunction f, parallel_options opt=parallel_options(0, Split_Y, 1))
WORK_API bool WorkHasConcurrency()
void WorkParallelForEach(InputIterator first, InputIterator last, Fn &&fn)
__hostdev__ uint64_t last(uint32_t i) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE