24 #ifndef PXR_BASE_WORK_REDUCE_H
25 #define PXR_BASE_WORK_REDUCE_H
32 #include <tbb/blocked_range.h>
33 #include <tbb/parallel_reduce.h>
34 #include <tbb/task_group.h>
98 template <
typename Fn,
typename Rn,
typename V>
104 Rn &&reductionCallback,
116 Work_Body_TBB(Fn &fn) : _fn(fn) { }
119 const tbb::blocked_range<size_t> &
r,
120 const V &
value)
const {
126 return std::forward<Fn>(_fn)(r.begin(), r.end(),
value);
134 tbb::task_group_context ctx(tbb::task_group_context::isolated);
135 return tbb::parallel_reduce(tbb::blocked_range<size_t>(0,n,grainSize),
137 Work_Body_TBB(loopCallback),
138 std::forward<Rn>(reductionCallback),
139 tbb::auto_partitioner(),
144 return std::forward<Fn>(loopCallback)(0, n, identity);
155 template <
typename Fn,
typename Rn,
typename V>
161 Rn &&reductionCallback)
168 #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