GPU Programming
Summing the same floating-point data on a GPU gives results whose last digits differ slightly from run to run. What is the most likely cause?
- AThe GPU's arithmetic units are broken
- BThe data is being altered inside the GPU each time
- CThe addition order varies between runs (for example with atomics), and floating-point addition rounds differently depending on order
Show answer and explanation
Answer: C. The addition order varies between runs (for example with atomics), and floating-point addition rounds differently depending on order
Floating-point addition rounds every time, so (a + b) + c and a + (b + c) can differ slightly. In a parallel sum, which thread's value is added in what order depends on thread scheduling and the arrival order of atomic operations. As a result, the last digits change between runs. When identical results are required, a reduction with a fixed addition order is used.
- A. It is normal and happens on healthy hardware.
- B. The data does not change.
- C. Correct. Floating-point addition is not associative.