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

Tracking Issue for f16 and f128 float types #116909

Open
3 tasks
traviscross opened this issue Oct 18, 2023 · 28 comments
Open
3 tasks

Tracking Issue for f16 and f128 float types #116909

traviscross opened this issue Oct 18, 2023 · 28 comments
Assignees
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-f16_and_f128 `#![feature(f16_and_f128)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@traviscross
Copy link
Contributor

traviscross commented Oct 18, 2023

This is a tracking issue for the RFC 3453 (rust-lang/rfcs#3453).

The feature gate for the issue is #![feature(f16_and_f128)].

From the RFC:

This RFC proposes adding new IEEE-compliant floating point types f16 and f128 into the core language and standard library. We will provide a soft float implementation for all targets, and use hardware support where possible.

About tracking issues

Tracking issues are used to record the overall progress of implementation. They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions. A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature. Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

Unresolved questions

None so far.

Implementation history

@traviscross traviscross added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Oct 18, 2023
@traviscross

This comment has been minimized.

@rustbot rustbot added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Oct 18, 2023
@traviscross

This comment has been minimized.

@rustbot rustbot added the B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. label Oct 19, 2023
@tgross35

This comment was marked as outdated.

@gorentbarak

This comment has been minimized.

@gorentbarak

This comment has been minimized.

@gorentbarak

This comment has been minimized.

@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 27, 2023
@gorentbarak

This comment has been minimized.

@rustbot

This comment has been minimized.

@gorentbarak

This comment has been minimized.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 27, 2023
@lqd

This comment has been minimized.

@lqd lqd removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 27, 2023
@traviscross traviscross added the F-f16_and_f128 `#![feature(f16_and_f128)]` label Nov 4, 2023
@tgross35
Copy link
Contributor

tgross35 commented Dec 9, 2023

A blocking issue should be added: ensure C compatibility with ABI-cafe or similar

#114607 (comment)

@tgross35
Copy link
Contributor

tgross35 commented Feb 28, 2024

Implementation steps (could somebody link this in the top post?):

This is based on the suggested pattern at #120645 (comment). I have a more complete reference PR with most of these done at #114607

I am trying to consistently use unimplemented!("f16_f128") and // FIXME(f16_f128) to make needed changes easily greppable.

Nice to have changes:

@rustbot claim

flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s

This was originally a PR against the Clippy repo, rust-lang#12950

r? ``@flip1995``

Tracking issue: rust-lang/rust#116909
Fixes: rust-lang/rust#126636
flip1995 pushed a commit to flip1995/rust-clippy that referenced this issue Jun 28, 2024
Add more constants, functions, and tests for `f16` and `f128`

This adds everything that was in some way blocked on const eval, since rust-lang/rust#126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change.

`f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64.

Tracking issue: rust-lang/rust#116909
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 5, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
@beetrees
Copy link
Contributor

beetrees commented Jul 8, 2024

It seems the LLVM f16 excess precision and ABI-handling bugs aren't limited to WASM:

The list of affected LLVM backends is included in each issue: both affect tier 2 and tier 3 Rust targets.

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 8, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 8, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 9, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 9, 2024
…rister

Add Natvis visualiser and debuginfo tests for `f16`

To render `f16`s in debuggers on MSVC targets, this PR changes the compiler to output `f16`s as `struct f16 { bits: u16 }`, and includes a Natvis visualiser that manually converts the `f16`'s bits to a `float` which is can then be displayed by debuggers. `gdb`, `lldb` and `cdb` tests are also included for `f16` .

`f16`/`f128` MSVC debug info issue: rust-lang#121837
Tracking issue: rust-lang#116909
GuillaumeGomez pushed a commit to GuillaumeGomez/rust that referenced this issue Jul 10, 2024
Refactor float `Primitive`s to a separate `Float` type

Now there are 4 of them, it makes sense to refactor `F16`, `F32`, `F64` and `F128` out of `Primitive` and into a separate `Float` type (like integers already are). This allows patterns like `F16 | F32 | F64 | F128` to be simplified into `Float(_)`, and is consistent with `ty::FloatTy`.

As a side effect, this PR also makes the `Ty::primitive_size` method work with `f16` and `f128`.

Tracking issue: rust-lang#116909

`@rustbot` label  F-f16_and_f128
@uweigand
Copy link
Contributor

The test suite currently fails on s390x in the following doctests:

    library/core/src/num/f16.rs - f16::f16::is_sign_negative (line 377)
    library/core/src/num/f16.rs - f16::f16::is_sign_positive (line 354)
    library/core/src/num/f16.rs - f16::f16::to_be_bytes (line 695)
    library/core/src/num/f16.rs - f16::f16::to_le_bytes (line 716)
    library/core/src/num/f16.rs - f16::f16::to_ne_bytes (line 743)

due to

rustc-LLVM ERROR: Cannot select: 0x3ffcc0737a0: i32 = fp_to_fp16 0x3ffcc072fc0

(which is llvm/llvm-project#50374)

After #127235 most doctests are already restricted to x64_64 (or aarch64), but these few listed above remain active on all Linux platforms. Could those also be restricted for now (until the s390x LLVM back-end is fixed) so that the test suite passes again? Thanks!

@tgross35
Copy link
Contributor

tgross35 commented Jul 10, 2024

Thanks for reporting @uweigand, yes those could be restricted too. Feel free to open a PR similar to #127235 if you're up for it, otherwise I'll try to put one up in the next couple days.

@uweigand
Copy link
Contributor

Thanks for reporting @uweigand, yes those could be restricted too. Feel free to open a PR similar to #127235 if you're up for it, otherwise I'll try to put one up in the next couple days.

I've now opened #127588, thanks!

@beetrees
Copy link
Contributor

LLVM lowers f16 FMA incorrectly on targets without native f16 FMA support (so this will affect most targets including all tier 1 targets): llvm/llvm-project#98389

@scottmcm
Copy link
Member

It appears that today f128 doesn't trigger the incomplete_features lint: https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=9d8a3698d5d506fc960bde270e9a1a54

It might be a good idea to do that for now, to avoid people making threads like https://users.rust-lang.org/t/display-for-f128/114405?u=scottmcm

bors added a commit to rust-lang-ci/rust that referenced this issue Jul 30, 2024
…indows-abi, r=<try>

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 30, 2024
…-windows-abi, r=tgross35

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
tgross35 added a commit to tgross35/rust that referenced this issue Jul 31, 2024
…-windows-abi, r=tgross35

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2024
…-windows-abi, r=tgross35

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jul 31, 2024
…-windows-abi, r=tgross35

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jul 31, 2024
Rollup merge of rust-lang#128388 - beetrees:f16-f128-slightly-improve-windows-abi, r=tgross35

Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: rust-lang#116909

try-job: x86_64-msvc
try-job: x86_64-mingw
@beetrees
Copy link
Contributor

beetrees commented Aug 2, 2024

Tier 3 powerpc64-ibm-aix doesn't currently support f128 arguments: llvm/llvm-project#101545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. F-f16_and_f128 `#![feature(f16_and_f128)]` T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

9 participants