7 #ifndef PXR_BASE_WORK_REDUCE_H
8 #define PXR_BASE_WORK_REDUCE_H
15 #include <tbb/blocked_range.h>
16 #include <tbb/parallel_reduce.h>
17 #include <tbb/task_group.h>
81 template <
typename Fn,
typename Rn,
typename V>
87 Rn &&reductionCallback,
99 Work_Body_TBB(Fn &fn) : _fn(fn) { }
102 const tbb::blocked_range<size_t> &
r,
103 const V &
value)
const {
109 return std::forward<Fn>(_fn)(r.begin(), r.end(),
value);
117 tbb::task_group_context ctx(tbb::task_group_context::isolated);
118 return tbb::parallel_reduce(tbb::blocked_range<size_t>(0,n,grainSize),
120 Work_Body_TBB(loopCallback),
121 std::forward<Rn>(reductionCallback),
122 tbb::auto_partitioner(),
127 return std::forward<Fn>(loopCallback)(0, n, identity);
138 template <
typename Fn,
typename Rn,
typename V>
144 Rn &&reductionCallback)
151 #endif // PXR_BASE_WORK_REDUCE_H
GLsizei const GLfloat * value
PXR_NAMESPACE_OPEN_SCOPE V WorkParallelReduceN(const V &identity, size_t n, Fn &&loopCallback, Rn &&reductionCallback, size_t grainSize)
WORK_API bool WorkHasConcurrency()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE