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

Switch to apfloat's FMA #2995

Open
RalfJung opened this issue Jul 27, 2023 · 2 comments
Open

Switch to apfloat's FMA #2995

RalfJung opened this issue Jul 27, 2023 · 2 comments
Labels
A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement

Comments

@RalfJung
Copy link
Member

RalfJung commented Jul 27, 2023

Currently Miri uses host floats for FMA. However it would of course be better to use softfloats. :)

Unfortunately apfloat still has some bugs around FMA, see llvm/llvm-project#63895 / rust-lang/rustc_apfloat#11. Those probably need to be resolved and ported to rustc_apfloat before we should use it in Miri.

Cc @eddyb

@RalfJung
Copy link
Member Author

Here's a testcase that currently behaves correctly in Miri but would fail if we were to switch to apfloat right now:

fn main() {
    let f = f32::mul_add(
        -0.000000000000000000000000000000000000014728589,
        0.0000037105144,
        0.000000000000000000000000000000000000000000055
    );
    assert_eq!(f, -0.0);
}

@eddyb
Copy link
Member

eddyb commented Jul 28, 2023

Here's a testcase that currently behaves correctly in Miri but would fail if we were to switch to apfloat right now:

Notably, it also fails when building and running w/ rustc, if optimizations are enabled.

@RalfJung RalfJung added C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement A-shims Area: This affects the external function shims labels Apr 18, 2024
bors added a commit that referenced this issue May 2, 2024
update host-float comments

Turns out most of these do not have guaranteed precision anyway so it's fine to use host floats (see rust-lang/rust#121793 and rust-lang/rust#118217). The exception are sqrt and mul_add, tracked at #3534 and #2995.
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 4, 2024
update host-float comments

Turns out most of these do not have guaranteed precision anyway so it's fine to use host floats (see rust-lang#121793 and rust-lang#118217). The exception are sqrt and mul_add, tracked at rust-lang/miri#3534 and rust-lang/miri#2995.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-shims Area: This affects the external function shims C-enhancement Category: a PR with an enhancement or an issue tracking an accepted enhancement
Projects
None yet
Development

No branches or pull requests

2 participants