A histogram of pair distances into 50 bins is filled by a compiled loop split over 8…
PHYSICS · Subjective · Fermi University Physics · Computational Physics · Research software practice, verification and validation · High-performance and data-driven computational physics
Scientific Computing for Physicists, Ch Many processors: speed-up, decomposition and the cost of communication
Problem
A histogram of 2×107 pair distances into 50 bins is filled by a compiled loop split over 8 threads, each thread incrementing the shared bin array directly (h[idx] += 1 inside the compiled loop). The code is run twice; both times the sum of all bins equals 2×107, matching the known total. Someone argues: "the two runs gave the exact right total, so this loop has no race condition and is safe to use in production." Evaluate the claim, explaining what a race condition does to a shared histogram and why two correct totals do not settle the question.