From ce0560c82b54cab222b5c3866154c114bf34b0df Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 6 Jan 2025 05:15:40 +0000 Subject: [PATCH 1/2] Enable MPFR tests on i586 MPFR does build and run correctly without SSE, but requires `force-cross` be enabled. --- ci/docker/i586-unknown-linux-gnu/Dockerfile | 2 +- ci/run.sh | 2 +- crates/libm-test/Cargo.toml | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/docker/i586-unknown-linux-gnu/Dockerfile b/ci/docker/i586-unknown-linux-gnu/Dockerfile index 3b0bfc0d3..37e206a84 100644 --- a/ci/docker/i586-unknown-linux-gnu/Dockerfile +++ b/ci/docker/i586-unknown-linux-gnu/Dockerfile @@ -2,4 +2,4 @@ FROM ubuntu:24.04 RUN apt-get update && \ apt-get install -y --no-install-recommends \ - gcc-multilib libc6-dev ca-certificates + gcc-multilib m4 make libc6-dev ca-certificates diff --git a/ci/run.sh b/ci/run.sh index 7e514a1cd..70fc271f1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -45,8 +45,8 @@ case "$target" in # FIXME(ci): we should be able to enable aarch64 Linux here once GHA # support rolls out. x86_64*) extra_flags="$extra_flags --features libm-test/test-multiprecision" ;; - # i686 works fine, i586 does not i686*) extra_flags="$extra_flags --features libm-test/test-multiprecision" ;; + i586*) extra_flags="$extra_flags --features libm-test/test-multiprecision --features gmp-mpfr-sys/force-cross" ;; # Apple aarch64 is native aarch64*apple*) extra_flags="$extra_flags --features libm-test/test-multiprecision" ;; esac diff --git a/crates/libm-test/Cargo.toml b/crates/libm-test/Cargo.toml index 2761d3d52..371beb19a 100644 --- a/crates/libm-test/Cargo.toml +++ b/crates/libm-test/Cargo.toml @@ -12,7 +12,7 @@ unstable-float = ["libm/unstable-float", "rug?/nightly-float"] # Generate tests which are random inputs and the outputs are calculated with # musl libc. -test-multiprecision = ["dep:az", "dep:rug"] +test-multiprecision = ["dep:az", "dep:rug", "dep:gmp-mpfr-sys"] # Build our own musl for testing and benchmarks build-musl = ["dep:musl-math-sys"] @@ -26,6 +26,7 @@ short-benchmarks = [] [dependencies] anyhow = "1.0.90" az = { version = "1.2.1", optional = true } +gmp-mpfr-sys = { version = "1.6.4", optional = true, default-features = false, features = ["mpfr"] } indicatif = { version = "0.17.9", default-features = false } libm = { path = "../..", features = ["unstable-public-internals"] } libm-macros = { path = "../libm-macros" } From 6328b101b10c688bbdabd3f8e215e0598b951e95 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Mon, 6 Jan 2025 20:27:48 +0000 Subject: [PATCH 2/2] Increase the allowed precision for failing tests on i586 These will need to be fixed, for now just xfail them so this doesn't block better test coverage. --- crates/libm-test/src/precision.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/libm-test/src/precision.rs b/crates/libm-test/src/precision.rs index 1a66a430c..03bf7cecc 100644 --- a/crates/libm-test/src/precision.rs +++ b/crates/libm-test/src/precision.rs @@ -104,11 +104,14 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 { // In some cases, our implementation is less accurate than musl on i586. if cfg!(x86_no_sse) { 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::Fmaf => ulp = 1, Id::Log1p | Id::Log1pf => ulp = 2, Id::Rint => ulp = 100_000, Id::Round => ulp = 1,