You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
regression/dotproduct fails at -n4096: fixed FLOAT_ULP 6 tolerance vs a sequential float reference (device result is more accurate) #450
(It passes at -n256. Seen on 7fe1936; tests/regression/dotproduct and FLOAT_ULP are unchanged on current master.)
The host reference sums the products sequentially in float, while the kernel sums one product per thread, reduces 16 per block as a tree, and adds the 256 block sums on the host. A float32 replay of both exact operation orders (same rand() inputs, srand(50)) gives:
value
error vs exact sum (1021.027040)
kernel order (matches simx bit-for-bit)
1021.027222
3 ulp
host reference (sequential)
1021.026794
4 ulp
So the device result is actually closer to the exact sum than the reference, but the two differ by 7 ulp and compare() allows a fixed FLOAT_ULP 6 regardless of n. The rounding error of a sequential float sum grows with n, so the test will fail for large enough n on any correct implementation.
Suggestion: compute the reference in double and compare with a relative tolerance that scales with n (e.g. about n·FLT_EPSILON·Σ|a·b|), or scale the ulp bound with log2(n) for the tree part plus the host's sequential part.
Activity
tinebp commentedon Nov 19, 2026
Fixed by #485.