10 #include <tbb/parallel_for.h>
11 #include <tbb/parallel_scan.h>
17 template <
class Tin,
class Tout>
24 ScanSumBody(Tout* out_,
const Tin* in_) : sum(0), in(in_), out(out_) {}
25 Tout get_sum()
const {
return sum; }
28 void operator()(
const tbb::blocked_range<size_t>& r, Tag) {
30 for (
size_t i = r.begin(); i < r.end(); ++i) {
32 if (Tag::is_final_scan()) out[i] = temp;
36 ScanSumBody(ScanSumBody& b, tbb::split) : sum(0), in(b.in), out(b.out) {}
37 void reverse_join(ScanSumBody& a) { sum = a.sum + sum; }
38 void assign(ScanSumBody& b) { sum = b.sum; }
42 template <
class Tin,
class Tout>
44 ScanSumBody<Tin, Tout> body(out, first);
45 size_t n = std::distance(first, last);
46 tbb::parallel_scan(tbb::blocked_range<size_t>(0, n), body);
void InclusivePrefixSum(const Tin *first, const Tin *last, Tout *out)
Definition: ParallelScan.h:43
Definition: PinholeCameraIntrinsic.cpp:16