Skip to content

easing_matches_python_bit_exactly fails on x86_64 CPUs without FMA (glibc libm variants) #56

Open

Description

@rofrol

Environment: ttfx v0.5.0 (112ebb3), Linux x86_64, glibc 2.41, Rust debug test build; Intel Core 2 Duo P8600 (SSE4.1, no AVX/AVX2/FMA).

cargo test fails tests/easing_goldens.rs:84 (easing_matches_python_bit_exactly) with 3 mismatches:

  • OutSine p=0.341: expected 3fe055235c33eb54, got 3fe055235c33eb55 (1 ulp)
  • InOutElastic p=0.396: expected bfbd6ccc9016b52a, got bfbd6ccc9016b529 (1 ulp)
  • CubicBezier(0.68, -0.55, 0.265, 1.55) p=0.379: expected 3fb521ea5f9f9f74, got 3fb521ea5f9f9f63 (17 ulp, 2.4e-16 absolute)

Cause: CPython 3.12 with the same glibc on the same CPU produces exactly the Rust values (0 ulp), so this is not Rust codegen. glibc's x86_64 libm selects sin/pow/exp/... implementations at runtime (FMA/AVX2 vs SSE2 variants). The goldens match the correctly rounded sin results, while the SSE2 sin is 1 ulp off for sin(0.5356415474370597) and sin(-4.4750242021134605). The bezier's Newton iterations amplify a last-bit libm difference to 17 ulp.

Suggestion: bit-exactness on "Linux/glibc" is CPU-dependent, so use the existing 1e-15 absolute tolerance there too (or an ulp bound with an absolute floor for values near zero). The largest measured difference is 2.36e-16.

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