4 ms·
If you don't care about cancellation error and are only concerned with perfect bitwise / reproducible results, then sort your numbers. Sorting the numbers is n
by dragontamer 7y ago
If you don't care about cancellation error and are only concerned with perfect bitwise / reproducible results, then sort your numbers.
Sorting the numbers is necessary to minimize cancellation error. But absolute minimum cancellation error can only be done sequentially: the parallel version may return different results.
l = list(s)
l.sort()
sum(l)
l = list(reversed(s))
l.sort()
sum(l)
Both return 1.111111111111111 now. Sorting is the "synchronization" step you need to get all your parallel tasks back into a defined order.