logoalt Hacker News

rzzzttoday at 2:38 PM3 repliesview on HN

The first one too? Isn't that the map-reduce fork-join golden example of multiprocessing?


Replies

cwzwarichtoday at 2:47 PM

`std::accumulate` is defined to have sequential semantics, so the analysis required to make it parallel is probably not that different than starting from the loop version. I guess you could have an alternate `accumulate_associative` that uses the same interface but assumes the reduction is associative and has unspecified evaluation order?

show 1 reply
CITIZENDOTtoday at 2:50 PM

std::accumulate is sequential and guarantes in order traversal. std::reduce is parallel version of it

tcfhgjtoday at 2:49 PM

1) afaik accumulate cannot be parallelized

2) the map part is included in the accumulate lambda, so the map part cannot be parallelized either -> you'd have to split it out into a transform step (iirc)