14#ifndef NANOVDB_REDUCE_H_HAS_BEEN_INCLUDED
15#define NANOVDB_REDUCE_H_HAS_BEEN_INCLUDED
20#include <tbb/parallel_reduce.h>
41template <
typename RangeT,
typename T,
typename FuncT,
typename JoinT>
44 if (range.empty())
return identity;
46 return tbb::parallel_reduce(range, identity,
func, join);
48 if (
const size_t threadCount = std::thread::hardware_concurrency()>>1) {
60 auto task = std::async(std::launch::async, [&](){
return func(r, identity);});
65 result = join(result, f.get());
69 return static_cast<T>(
func(range, identity));
76template <
typename T,
typename FuncT,
typename JoinT >
79 Range1D range(begin, end, grainSize);
84template <
template<
typename...>
class ContainerT,
typename... ArgT,
typename T,
typename FuncT,
typename JoinT >
93template <
template<
typename...>
class ContainerT,
typename... ArgT,
typename T,
typename FuncT,
typename JoinT >
Custom Range class that is compatible with the tbb::blocked_range classes.
Definition DenseGrid.h:402
uint64_t size() const
Returns the size in bytes of the raw memory buffer managed by this DenseGridHandle's allocator.
Definition DenseGrid.h:440
T reduce(RangeT range, const T &identity, const FuncT &func, const JoinT &join)
Definition Reduce.h:42