core::num::f16b Rust's 16bit Brain Float - #160859
Jamesbarford wants to merge 5 commits into
Conversation
|
Some changes occurred in compiler/rustc_attr_ir cc @jdonszelmann, @JonathanBrouwer This PR changes rustc_public cc @oli-obk, @celinval, @ouz-a, @makai410
|
|
r? @jieyouxu rustbot has assigned @jieyouxu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
@rustbot reroll |
| } | ||
|
|
||
| fn type_f16b(&self) -> Type<'gcc> { | ||
| bug!("f16b is not supported by the GCC codegen backend") |
There was a problem hiding this comment.
I believe GCC actually supports this type: https://github.com/rust-lang/gccjit.rs/blob/master/src/context.rs#L1482
There was a problem hiding this comment.
Thanks 😄, I will aim to add it in a follow up PR 👍
There was a problem hiding this comment.
Actually, as @folkertdev pointed out, it was a doddle. So I've included the implementation in the PR 👍
bf10f8a to
01c5c1b
Compare
|
cc @bjorn3 |
This comment has been minimized.
This comment has been minimized.
53d3660 to
40d3f6e
Compare
This comment has been minimized.
This comment has been minimized.
da620d0 to
0ed984f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in cfg and check-cfg configuration cc @Urgau
cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
|
I'm not a good reviewer for this change. Can somebody here pick it up rather than blindly rerolling? |
|
r? me |
|
This pull request was unapproved. This PR was contained in a rollup (#162918), which was unapproved. |
|
Ah, I think that is just a conflict between PRs in that rollup, specifically #161987. So we should just let that merge and then add this back to the queue. |
|
@Jamesbarford can you rebase and fix that conflict? |
4ff2c1d to
8dd27f8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
8dd27f8 to
c1287ce
Compare
|
@rustbot ready |
|
@bors r+ |
…ertdev `core::num::f16b` Rust's 16bit Brain Float Implements the [RFC: f16b type](rust-lang/rfcs#3983). Best reviewed commit by commit, happy to split into separate PRs if that is deemed easier to review. However the line count and surface area is, in my opinion, reasonably small. Adds; - ABI plumbing for the `f16b` along with `bfloat` lang item to work with LLVM, GCC is explicitly `unimplemented!(...)` - `f16b` feature gate, page for `f16b` on libruscdoc and a `struct bf16` in `core::num` - Tests - Treat `f16b` as a scalar primitive for scalable vectors Issues; - [Tracking Issue](rust-lang#160630) - [RFC](rust-lang/rfcs#3983)
…uwer Rollup of 8 pull requests Successful merges: - #160859 (`core::num::f16b` Rust's 16bit Brain Float) - #162177 (Properly implement the gpu-kernel ABI for amdgpu) - #162591 (Move parse error recovery for expression operators "out of line" & refactor in the area) - #162733 (Add useful APIs to `Unique(Arc|Rc)`) - #162950 (More AST lowering cleanups) - #162964 (Update `browser-ui-test` version to `0.25.2`) - #162797 (yeet AliasConstKind::opt_def_id) - #162836 (Ping T-libs-ping instead of T-libs-fcp for backports)
|
💔 I suspect this PR failed tests as part of a rollup After fixing the problem, consider running a try job for the failed job before re-approving. Link to failure: #162975 (comment) |
|
This pull request was unapproved. This PR was contained in a rollup (#162975), which was unapproved. |
|
Hmm, GCC 11 is very old (current version is 16), I suspect it just does not have this symbol? Did we get unlucky with the runner just having a really old GCC? Or maybe this conversion is normally optimized out but not at opt level 0. Anyhow, I'd just add |
|
Could somebody with this built dump the unoptimized LLVM IR for that test? |
|
I imagine adding |
(The IR dump is huge so I've made it a markdown dropdown thingy) Unoptimised LLVM-IR DumpGetting the text-based assembly on an x86_64 machine some of the functions like _RNvMNtNtCsaWjkfsaqAJ7_4core3num6bfloatNtB2_4f16b7to_bitsCsdEmYN0yN6GW_4f16b:
.cfi_startproc
pushq %rax
.cfi_def_cfa_offset 16
pextrw $0, %xmm0, %eax
movw %ax, %cx
movw %cx, %ax
shll $16, %eax
movd %eax, %xmm0
movq __truncsfbf2@GOTPCREL(%rip), %rax
callq *%rax
pextrw $0, %xmm0, %eax
popq %rcx
.cfi_def_cfa_offset 8
retq
_RNvXs4_NtNtCsaWjkfsaqAJ7_4core3num6bfloatfINtNtB9_7convert4FromNtB5_4f16bE4fromCsdEmYN0yN6GW_4f16b:
.cfi_startproc
pushq %rax
.cfi_def_cfa_offset 16
pextrw $0, %xmm0, %eax
movw %ax, %cx
movw %cx, %ax
shll $16, %eax
movd %eax, %xmm0
movq __truncsfbf2@GOTPCREL(%rip), %rax
callq *%rax
pextrw $0, %xmm0, %eax
movzwl %ax, %eax
shll $16, %eax
movd %eax, %xmm0
popq %rax
.cfi_def_cfa_offset 8
retqAnd then somewhere in main there is a Compiling with I've added a fixme to the test and |
|
Ah it's the issue beetrees mentioned above, llvm/llvm-project#97896. Unfortunately (The new |
View all comments
Implements the RFC: f16b type. Best reviewed commit by commit, happy to split into separate PRs if that is deemed easier to review. However the line count and surface area is, in my opinion, reasonably small.
Adds;
f16balong withbfloatlang item to work with LLVM, GCC is explicitlyunimplemented!(...)f16bfeature gate, page forf16bon libruscdoc and astruct bf16incore::numf16bas a scalar primitive for scalable vectorsIssues;