Skip to content

regression/dotproduct fails at -n4096: fixed FLOAT_ULP 6 tolerance vs a sequential float reference (device result is more accurate) #450

Closed

Description

@LucideLarp

tests/regression/dotproduct fails at larger sizes because of the test's tolerance, not because of a wrong result from the GPU:

$ ./ci/blackbox.sh --driver=simx --app=dotproduct --args=-n4096
...
*** error: [0] expected=1021.026794, actual=1021.027222
Found 1 errors!
FAILED!

(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

  1. tinebp commented on Nov 19, 2026

    @tinebp
    Collaborator

    Fixed by #485.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions