Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specific test failures #401

Open
tgross35 opened this issue Jan 6, 2025 · 11 comments
Open

Specific test failures #401

tgross35 opened this issue Jan 6, 2025 · 11 comments

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jan 6, 2025

Just making a list of failures that should be turned into xfails or fixed.

My loose plan is to put all of these into a single test file and assert that they fail, then if they get fixed they can be converted to test cases.


i586-unknown-linux-gnu from on #379, musl's result is more accurate.

thread 'musl_random_asinhf' panicked at crates/libm-test/tests/compare_built_musl.rs:43:51:
called `Result::unwrap()` on an `Err` value:
    input:    (-0.37330312,) (0xbebf2196,)
    expected: -0.36513534            0xbebaf305
    actual:   -0.36513525            0xbebaf302

i686-unknown-linux-gnu from on #379, musl has the incorrect result here. Not sure why this would be, is compiler-rt incorrect?

 thread 'musl_random_fdim' panicked at crates/libm-test/tests/compare_built_musl.rs:43:51:
called `Result::unwrap()` on an `Err` value: 
    input:    (5.1720626866622296e88, -5.1749184040104636e103) (0x5259ffdf64f0d2f8, 0xd5771addd21280b5)
    expected: 5.174918404010469e103  0x55771addd21280bc
    actual:   5.174918404010468e103  0x55771addd21280bb

Caused by:
    ulp 1 > 0
@tgross35
Copy link
Contributor Author

tgross35 commented Jan 6, 2025

i586 at https://github.com/rust-lang/libm/actions/runs/12639597612/job/35218274466?pr=404

---- mp_random_fdim stdout ----
Random Mpfr fdim arg 1/2: 100 iterations (10000 total) using `LIBM_SEED=xcGcTkg83bx6IACwhIJGBEnglUPE38Ik`
Random Mpfr fdim arg 2/2: 100 iterations (10000 total) using `LIBM_SEED=xcGcTkg83bx6IACwhIJGBEnglUPE38Ik`

thread 'mp_random_fdim' panicked at crates/libm-test/tests/multiprecision.rs:41:49:
called `Result::unwrap()` on an `Err` value: 
    input:    (2.562129982717898e-287, -1.64014759986637e-294) (0x046f3600eb4ad0e0, 0x82f0c29b2b40023d)
    expected: 2.562130146732658e-287 0x046f36010cd00737
    actual:   2.5621301467326578e-287 0x046f36010cd00736

Caused by:
    ulp 1 > 0

@tgross35
Copy link
Contributor Author

---- mp_random_rint stdout ----
Random Mpfr rint arg 1/1: 10000 iterations (10000 total) using `LIBM_SEED=Fl1f69DaJnwkHN2FeuCXaBFRvJYsPvEY`

thread 'mp_random_rint' panicked at crates/libm-test/tests/multiprecision.rs:41:49:
called `Result::unwrap()` on an `Err` value:
    input:    (-849751480.5001163,) (0xc1c95316dc4003d0,)
    expected: -849751481.0           0xc1c95316dc800000
    actual:   -849751480.0           0xc1c95316dc000000

Caused by:
    ulp 8388608 > 100000

Increase in #428

@tgross35
Copy link
Contributor Author

tgross35 commented Jan 12, 2025

There was actually a worse failure on the master CI:

---- mp_random_rint stdout ----
Random Mpfr rint arg 1/1: 10000 iterations (10000 total) using `LIBM_SEED=XN7VCGhX3Wu6Mzn8COvJPITyZlGP7gN7`

thread 'mp_random_rint' panicked at crates/libm-test/tests/multiprecision.rs:41:49:
called `Result::unwrap()` on an `Err` value: 
    input:    (-12493089.499809155,) (0xc167d4242ffe6fc5,)
    expected: -12493089.0            0xc167d42420000000
    actual:   -12493090.0            0xc167d42440000000

Caused by:
    ulp 536870912 > 100000

Just the wrong rounding mode.

 ---- mp_random_rint stdout ----
Random Mpfr rint arg 1/1: 10000 iterations (10000 total) using `LIBM_SEED=v8xcuQAOi9x5FQE2UlbyZcDRmeEc2hYv`

thread 'mp_random_rint' panicked at crates/libm-test/tests/multiprecision.rs:41:49:
called `Result::unwrap()` on an `Err` value: 
    input:    (-1308.5000830345912,) (0xc094720015c45b6a,)
    expected: -1309.0                0xc094740000000000
    actual:   -1308.0                0xc094700000000000

Caused by:
    TryFromIntError(()): ulp of 4398046511104 exceeds u32::MAX

@tgross35
Copy link
Contributor Author

On i586 and i686, from #415:

---- mp_edge_case_fma stdout ----
EdgeCases Mpfr fma arg 1/3: 84 edge cases
EdgeCases Mpfr fma arg 2/3: 84 edge cases
EdgeCases Mpfr fma arg 3/3: 84 edge cases

thread 'mp_edge_case_fma' panicked at crates/libm-test/tests/multiprecision.rs:17:48:
called `Result::unwrap()` on an `Err` value: 
    input:    (0.999999999999999, 1.0000000000000013, 0.0) (0x3feffffffffffff7, 0x3ff0000000000006, 0x0000000000000000)
    expected: 1.0000000000000002     0x3ff0000000000001
    actual:   1.0000000000000004     0x3ff0000000000002

Caused by:
    ulp 1 > 0

@tgross35
Copy link
Contributor Author

---- musl_random_ynf stdout ----
Random Musl ynf arg 1/2: 100 iterations (10000 total) using `LIBM_SEED=nmcFKcyckEgzuvMXiW8sCBkVPIkV3his`
Random Musl ynf arg 2/2: 100 iterations (10000 total) using `LIBM_SEED=nmcFKcyckEgzuvMXiW8sCBkVPIkV3his`

thread 'musl_random_ynf' panicked at crates/libm-test/tests/compare_built_musl.rs:44:51:
called `Result::unwrap()` on an `Err` value: 
    input:    (228, 120.75621) (0x000000e4, 0x42f1832e)
    expected: -3.3293823e38          0xff7a7992
    actual:   -inf                   0xff800000

Caused by:
    mismatched infinities

@tgross35
Copy link
Contributor Author

From a random test on i686


thread 'main' panicked at crates/libm-test/benches/random.rs:76:65:
called `Result::unwrap()` on an `Err` value: ynf

Caused by:
    0: 
           input:    (148, 61.379253) (0x00000094, 0x4275845b)
           expected: -3.2585946e38          0xff752640
           actual:   -inf                   0xff800000
    1: mismatched infinities

@quaternic
Copy link
Contributor

The above problem with fma on i586 is due to f64 * f64 being just as broken on the target. Tracking issue: rust-lang/rust#114479

Specifically fma(0.999999999999999, 1.0000000000000013, 0.0) ends up at https://github.com/rust-lang/libm/blob/abf0a2813e232c5a903f715a8ecbbfa6f74b6e94/src/math/fma.rs#L59C13-L59C30 computing the product which rounds incorrectly due to double-rounding.

@tgross35
Copy link
Contributor Author

The i586 failure isn't too surprising, we are accumulating quite a few of those

match ctx.fn_ident {
// FIXME(#401): these need to be correctly rounded but are not.
Id::Fmaf => ulp = 1,
Id::Fdim => ulp = 1,
Id::Asinh => ulp = 3,
Id::Asinhf => ulp = 3,
Id::Exp10 | Id::Exp10f => ulp = 1_000_000,
Id::Exp2 | Id::Exp2f => ulp = 10_000_000,
Id::Log1p | Id::Log1pf => ulp = 2,
Id::Round => ulp = 1,
Id::Tan => ulp = 2,
_ => (),
}
. This also failed on i686 though which shouldn't have that problem, right? I didn't look into it too much.

Some of the i586 issues will probably get better once we port more of the x87 asm routines, but I don't think this helps FMA. (Which is probably fine, Rust's platform support docs mention the floating point noncompliance on this target)

@quaternic
Copy link
Contributor

quaternic commented Jan 14, 2025

Having the same bug for i686 didn't make sense, since that should be using SSE for the arithmetic.

Diving into the CI logs;

i586:
https://github.com/rust-lang/libm/actions/runs/12756874080/job/35555978637

thread 'mp_edge_case_fma' panicked at crates/libm-test/tests/multiprecision.rs:17:48:
called `Result::unwrap()` on an `Err` value: 
    input:    (0.999999999999999, 1.0000000000000013, 0.0) (0x3feffffffffffff7, 0x3ff0000000000006, 0x0000000000000000)
    expected: 1.0000000000000002     0x3ff0000000000001
    actual:   1.0000000000000004     0x3ff0000000000002

Caused by:
    ulp 1 > 0

i686:
https://github.com/rust-lang/libm/actions/runs/12756874080/job/35555978927

thread 'musl_edge_case_fma' panicked at crates/libm-test/tests/compare_built_musl.rs:26:51:
called `Result::unwrap()` on an `Err` value: 
    input:    (0.999999999999999, 1.0000000000000013, 0.0) (0x3feffffffffffff7, 0x3ff0000000000006, 0x0000000000000000)
    expected: 1.0000000000000004     0x3ff0000000000002
    actual:   1.0000000000000002     0x3ff0000000000001

Caused by:
    ulp 1 > 0

The expected and actual are flipped. I think i686 was failing because it's expecting to match the incorrect result from musl.

edit: And the failing test is indeed different: i586 failed when comparing to mpfr.

@tgross35
Copy link
Contributor Author

Thanks for finding that, I should have looked closer. I'll update precision.rs to increase the precision only when checking against musl.

@tgross35
Copy link
Contributor Author

aarch64-apple-darwin at https://github.com/rust-lang/libm/actions/runs/12779083571/job/35623106291

 ──── STDERR:             libm-test::compare_built_musl musl_random_ynf
Random Musl ynf arg 1/2: 29 iterations (841 total) using `LIBM_SEED=JXAfYmoTbXp14o5ccanIiZTWGlkabFzy`
Random Musl ynf arg 2/2: 29 iterations (841 total) using `LIBM_SEED=JXAfYmoTbXp14o5ccanIiZTWGlkabFzy`

thread 'musl_random_ynf' panicked at crates/libm-test/tests/compare_built_musl.rs:44:51:
called `Result::unwrap()` on an `Err` value: 
    input:    (184, 87.26689) (0x000000b8, 0x42ae88a6)
    expected: -3.2943882e38          0xff77d79c
    actual:   -inf                   0xff800000

Caused by:
    mismatched infinities

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants