Skip to content

Commit

Permalink
Check updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Oct 27, 2024
1 parent fd82c65 commit 448d351
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
6 changes: 4 additions & 2 deletions crates/libm-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ pub fn multiprec_allowed_ulp(name: &str) -> u32 {
"asinh" | "asinhf" => 2,
"atanh" | "atanhf" => 2,
"exp10" | "exp10f" => 3,
"j0" | "j0f" => 2,
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 2,
"j0" | "j0f" | "j1" | "j1f" => 16,
"jn" | "jnf" => 2000,
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 16,
"sinh" | "sinhf" => 2,
"sincosf" => 50,
"tanh" | "tanhf" => 2,
"tgamma" => 6,
_ => MULTIPREC_DEFAULT_ULP,
Expand Down
65 changes: 41 additions & 24 deletions crates/libm-test/src/special_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ impl MaybeOverride<(f32,)> for SpecialCase {
ctx: &CheckCtx,
) -> Option<TestResult> {
if ctx.basis == CheckBasis::Musl {
if ctx.fname == "acoshf" && input.0 < -1.0 {
// acoshf is undefined for x <= 1.0, but we return a random result at lower
// values.
return XFAIL;
}

if ctx.fname == "sincosf" {
let factor_frac_pi_2 = input.0.abs() / f32::consts::FRAC_PI_2;
if (factor_frac_pi_2 - factor_frac_pi_2.round()).abs() < 1e-2 {
Expand All @@ -82,11 +76,17 @@ impl MaybeOverride<(f32,)> for SpecialCase {
// doesn't seem to happen on x86
return XFAIL;
}
}

if ctx.fname == "lgammaf" || ctx.fname == "lgammaf_r" && input.0 < 0.0 {
// loggamma should not be defined for x < 0, yet we both return results
return XFAIL;
}
if ctx.fname == "acoshf" && input.0 < -1.0 {
// acoshf is undefined for x <= 1.0, but we return a random result at lower
// values.
return XFAIL;
}

if ctx.fname == "lgammaf" || ctx.fname == "lgammaf_r" && input.0 < 0.0 {
// loggamma should not be defined for x < 0, yet we both return results
return XFAIL;
}

maybe_check_nan_bits(actual, expected, ctx)
Expand Down Expand Up @@ -136,11 +136,17 @@ impl MaybeOverride<(f64,)> for SpecialCase {
// musl returns -0.0, we return +0.0
return XFAIL;
}
}

if ctx.fname == "lgamma" || ctx.fname == "lgamma_r" && input.0 < 0.0 {
// loggamma should not be defined for x < 0, yet we both return results
return XFAIL;
}
if ctx.fname == "acosh" && input.0 < 1.0 {
// The function is undefined for the inputs, musl and our libm both return
// random results.
return XFAIL;
}

if ctx.fname == "lgamma" || ctx.fname == "lgamma_r" && input.0 < 0.0 {
// loggamma should not be defined for x < 0, yet we both return results
return XFAIL;
}

maybe_check_nan_bits(actual, expected, ctx)
Expand Down Expand Up @@ -188,7 +194,7 @@ impl MaybeOverride<(f32, f32)> for SpecialCase {
_ulp: &mut u32,
ctx: &CheckCtx,
) -> Option<TestResult> {
maybe_skip_min_max_nan(input, expected, ctx)
maybe_skip_binop_nan(input, expected, ctx)
}
}
impl MaybeOverride<(f64, f64)> for SpecialCase {
Expand All @@ -199,24 +205,35 @@ impl MaybeOverride<(f64, f64)> for SpecialCase {
_ulp: &mut u32,
ctx: &CheckCtx,
) -> Option<TestResult> {
maybe_skip_min_max_nan(input, expected, ctx)
maybe_skip_binop_nan(input, expected, ctx)
}
}

/// Musl propagates NaNs if one is provided as the input, but we return the other input.
// F1 and F2 are always the same type, this is just to please generics
fn maybe_skip_min_max_nan<F1: Float, F2: Float>(
fn maybe_skip_binop_nan<F1: Float, F2: Float>(
input: (F1, F1),
expected: F2,
ctx: &CheckCtx,
) -> Option<TestResult> {
if (ctx.canonical_name == "fmax" || ctx.canonical_name == "fmin")
&& (input.0.is_nan() || input.1.is_nan())
&& expected.is_nan()
{
return XFAIL;
} else {
None
match ctx.basis {
CheckBasis::Musl => {
if (ctx.canonical_name == "fmax" || ctx.canonical_name == "fmin")
&& (input.0.is_nan() || input.1.is_nan())
&& expected.is_nan()
{
XFAIL
} else {
None
}
}
CheckBasis::MultiPrecision => {
if ctx.canonical_name == "copysign" && input.1.is_nan() {
SKIP
} else {
None
}
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion crates/libm-test/tests/multiprecision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ macro_rules! multiprec_rand_tests {
let mp_res = mp_vals.run(input);
let crate_res = input.call(libm::$fn_name as $RustFn);

mp_res.validate(crate_res, input, &ctx).unwrap();
crate_res.validate(mp_res, input, &ctx).unwrap();
}
}
}
Expand All @@ -58,5 +58,8 @@ libm_macros::for_each_function! {
remquof,
scalbn,
scalbnf,

jn,
jnf,
],
}

0 comments on commit 448d351

Please sign in to comment.