3 ms·
1000 threads can run in parallel. It doesn't prevent us to sum their results deterministically: results = ThreadPool(workers=1000).imap_unordered(calc, inp
by d0mine 3y ago
1000 threads can run in parallel. It doesn't prevent us to sum their results deterministically:
results = ThreadPool(workers=1000).imap_unordered(calc, inputs)
print(math.fsum(results))
Due to the magic of the fsum alg, the result is deterministic whatever order we get results in.
https://docs.python.org/3/library/math.html#math.fsum https://docs.python.org/3/library/math.html#math.fsum
- cpgxiii 3y agoThat's not the operation being performed on GPUs that is the problem. The issue is that fundamentally GPUs allow for high performance operations using atomics, but this comes at the cost of nondeterministic results. You can get deterministic results but doing so comes with a significant performance costs.
- xiphias2 3y agoUsing atomics is easier than warp operations (using warp shuffle for example), but warp shuffle is quite fast. I guess if determinism is so important implementations can be changed, it is just maybe not that high priority.
- WithinReason 3y agoThat summation is slow and would not be used in practice. You could use just one thread on your 10000 thread GPU too and it would be deterministic, sure. Completely beside the point.