Add an xfail for recent ynf failures

This failed a couple of times recently in CI, once on i686 and once on
aarch64-apple:

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

    Caused by:
        0:
               input:    (681, 509.90924) (0x000002a9, 0x43fef462)
               expected: -3.2161271e38          0xff71f45b
               actual:   -inf                   0xff800000
        1: mismatched infinities

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

    Caused by:
        0:
               input:    (132, 50.46604) (0x00000084, 0x4249dd3a)
               expected: -3.3364996e38          0xff7b02a5
               actual:   -inf                   0xff800000
        1: mismatched infinities

Add a new override to account for this.
This commit is contained in:
Trevor Gross 2025-01-16 09:47:00 +00:00
parent 5139ba6f46
commit 3986206ce0

View file

@ -4,6 +4,7 @@
use core::f32;
use CheckBasis::{Mpfr, Musl};
use libm::support::CastFrom;
use {BaseName as Bn, Identifier as Id};
use crate::{BaseName, CheckBasis, CheckCtx, Float, Identifier, Int, TestResult};
@ -524,7 +525,7 @@ impl MaybeOverride<(i32, f32)> for SpecialCase {
ctx: &CheckCtx,
) -> Option<TestResult> {
match (&ctx.basis, ctx.base_name) {
(Musl, _) => bessel_prec_dropoff(input, ulp, ctx),
(Musl, _) => bessel_prec_dropoff(input, actual, expected, ulp, ctx),
// We return +0.0, MPFR returns -0.0
(Mpfr, BaseName::Jn | BaseName::Yn)
@ -554,7 +555,7 @@ impl MaybeOverride<(i32, f64)> for SpecialCase {
ctx: &CheckCtx,
) -> Option<TestResult> {
match (&ctx.basis, ctx.base_name) {
(Musl, _) => bessel_prec_dropoff(input, ulp, ctx),
(Musl, _) => bessel_prec_dropoff(input, actual, expected, ulp, ctx),
// We return +0.0, MPFR returns -0.0
(Mpfr, BaseName::Jn | BaseName::Yn)
@ -569,8 +570,10 @@ impl MaybeOverride<(i32, f64)> for SpecialCase {
}
/// Our bessel functions blow up with large N values
fn bessel_prec_dropoff<F: Float>(
input: (i32, F),
fn bessel_prec_dropoff<F1: Float, F2: Float>(
input: (i32, F1),
actual: F2,
expected: F2,
ulp: &mut u32,
ctx: &CheckCtx,
) -> Option<TestResult> {
@ -585,6 +588,17 @@ fn bessel_prec_dropoff<F: Float>(
}
}
// Values near infinity sometimes get cut off for us. `ynf(681, 509.90924) = -inf` but should
// be -3.2161271e38.
if ctx.fn_ident == Identifier::Ynf
&& !expected.is_infinite()
&& actual.is_infinite()
&& (expected.abs().to_bits().abs_diff(actual.abs().to_bits())
< F2::Int::cast_from(1_000_000u32))
{
return XFAIL;
}
None
}