10 #include <tbb/parallel_for.h>
11 #include <tbb/parallel_scan.h>
13 #if TBB_INTERFACE_VERSION >= 20000
18 #ifdef __cpp_lib_parallel_algorithm
22 #include <pstl/execution>
23 #include <pstl/numeric>
29 #if __PSTL_CPP17_EXECUTION_POLICIES_PRESENT
30 #include <pstl/internal/glue_execution_defs.h>
40 template <
class Tin,
class Tout>
47 ScanSumBody(Tout* out_,
const Tin* in_) : sum(0), in(in_), out(out_) {}
48 Tout get_sum()
const {
return sum; }
51 void operator()(
const tbb::blocked_range<size_t>& r, Tag) {
53 for (
size_t i = r.begin(); i < r.end(); ++i) {
55 if (Tag::is_final_scan()) out[i] = temp;
59 ScanSumBody(ScanSumBody& b, tbb::split) : sum(0), in(b.in), out(b.out) {}
60 void reverse_join(ScanSumBody& a) { sum = a.sum + sum; }
61 void assign(ScanSumBody& b) { sum = b.sum; }
65 template <
class Tin,
class Tout>
67 #if TBB_INTERFACE_VERSION >= 20000
69 std::inclusive_scan(pstl::execution::par_unseq, first, last, out);
71 ScanSumBody<Tin, Tout> body(out, first);
72 size_t n = std::distance(first, last);
73 tbb::parallel_scan(tbb::blocked_range<size_t>(0, n), body);
void InclusivePrefixSum(const Tin *first, const Tin *last, Tout *out)
Generic file read and write utility for python interface.