29 #include <tbb/parallel_for.h> 31 #include "tbb/parallel_scan.h" 32 #if TBB_INTERFACE_VERSION >= 10000 33 #include "pstl/execution" 34 #include "pstl/numeric" 41 template <
class Tin,
class Tout>
48 ScanSumBody(Tout* out_,
const Tin* in_) : sum(0), in(in_), out(out_) {}
49 Tout get_sum()
const {
return sum; }
52 void operator()(
const tbb::blocked_range<size_t>& r, Tag) {
54 for (
size_t i = r.begin(); i < r.end(); ++i) {
56 if (Tag::is_final_scan()) out[i] = temp;
60 ScanSumBody(ScanSumBody& b, tbb::split) : sum(0), in(b.in), out(b.out) {}
61 void reverse_join(ScanSumBody& a) { sum = a.sum + sum; }
62 void assign(ScanSumBody& b) { sum = b.sum; }
66 template <
class Tin,
class Tout>
68 #if TBB_INTERFACE_VERSION >= 10000 70 std::inclusive_scan(pstl::execution::par_unseq, first, last, out);
72 ScanSumBody<Tin, Tout> body(out, first);
73 size_t n = std::distance(first, last);
74 tbb::parallel_scan(tbb::blocked_range<size_t>(0, n), body);
void InclusivePrefixSum(const Tin *first, const Tin *last, Tout *out)
Definition: ParallelScan.h:67
Definition: PinholeCameraIntrinsic.cpp:35