Skip to content

Print full-precision mismatch values in CPU and GPU test helpers #1159

Description

@IvanaGyro

Problem

AreNearlyEqStorage prints mismatched values through std::cout using the default stream precision. For floating-point differences below roughly six significant digits, the comparison can fail while the diagnostic prints two values that look identical.

This was noted in the review discussion on #1148:
#1148 (comment)

The same implementation exists in both test helper paths:

  • tests/test_tools.cpp for CPU tests
  • tests/gpu/gpu_test_tools.cpp for GPU tests

Proposed change

Use sufficient precision when printing floating-point and complex mismatch values in both helpers. For double-precision values, this can be std::setprecision(17) or, preferably, std::numeric_limits<double>::max_digits10.

The implementation should avoid leaking modified formatting state through the global std::cout stream, for example by restoring the previous precision or formatting through a local stream.

Acceptance criteria

  • CPU and GPU AreNearlyEqStorage diagnostics show distinguishable values when a mismatch occurs beyond the default six-digit precision.
  • Complex values receive equivalent full-precision diagnostics.
  • Integer and boolean diagnostics remain readable and unchanged in meaning.
  • Printing a mismatch does not permanently change the formatting state of std::cout.

— Issue opened by GPT-5.6 Thinking on behalf of @IvanaGyro

Activity

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