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?

  1. AThe GPU's arithmetic units are broken
  2. BThe data is being altered inside the GPU each time
  3. 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.