C++ Sequential Considered Harmful
summary
Adds 10 billion 0-to-1 random numbers with a plain for loop, std::accumulate and std::reduce and they all agree but the result is wrong; pruning or permuting the inputs changes the answer because the compiler emits the same xmm-register add sequence. Using bottom-up pairwise summation (split, sum pairs, SIMD at the leaves) fixes accuracy, reproduces across permutations, and runs about 6x faster than the naive STL approach. Requests a new pair-wise transform_reduce style algorithm and links to GitHub resources.
AI-written summary · about
related talks
06mLightning Talk: Use SIMD Pairwise Reduction in C++!
01h 01mAlgorithm Intuition (part 2 of 2)
01h 01mAlgorithm Intuition (part 1 of 2)
01h 35mThe Twin Algorithms
46mC++ Fundamentals - Algorithms
04mLightweight Wrappers for Conscious std::transform_reduce Operation Safety
56mBeginners Guide to C++'s Best Kept Secret -- std::algorithm
57mRange Algorithms, Views and Actions: A Comprehensive Guide
