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

Define BFloat16 intrinsics #293

Merged
merged 18 commits into from
May 21, 2024
Merged

Define BFloat16 intrinsics #293

merged 18 commits into from
May 21, 2024

Conversation

eopXD
Copy link
Collaborator

@eopXD eopXD commented Nov 4, 2023

NOTE: This PR currently is based upon #292

NOTE: These new intrinsics introduced are not part of the to-be-frozen v1.0 intrinsics specification. These new intrinsics will not be cherry-picked to the v1.0.x branch.

This pull request defines intrinsics for vector bfloat16 type manipulations and vector instructions that are introduced by the RISC-V BFloat16 instruction set extensions (zvfbfmin and zvfbfwma) [0].

Intrinsics introduced for vector bfloat16 type manipulation:

  • (Non-segment/Segment) loads and stores around the vector bfloat16 types.
  • Utility intrinsics like vcreate, vundefined, ... etc (you may find the exact list under generated prototypes and its declarations under bfloat16_inst.py)

New intrinsics are added to expose new instructions introduced:

  • vfwmaccbf16.vv vd, vs1, vs2, vm
  • vfwmaccbf16.vf vd, rs1, vs2, vm
  • vfncvtbf16.f.f.w vd, vs2, vm
  • vfwcvtbf16.f.f.v vd, vs2, vm

[0] https://github.com/riscv/riscv-bfloat16

@eopXD eopXD changed the base branch from main to eopc/amendments-and-fixes November 4, 2023 18:03
Copy link
Collaborator

@rofirrim rofirrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using __bf16 for the scalar type, can we add a reference to some specification about this name?

Other than that, everything else LGTM.

@dzaima
Copy link

dzaima commented Nov 9, 2023

Shouldn't __riscv_vreinterpret_v_ui16m1_bf16m1 be __riscv_vreinterpret_v_u16m1_bf16m1 (i.e. u16 instead of ui16) as it is in all current vuint16m1_t type abbreviations?

@kito-cheng
Copy link
Collaborator

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#cc-type-sizes-and-alignments

__bf16 has used in psABI, but we may also need to add that to c-api-doc https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md for more complete documentation for that type.

@eopXD eopXD force-pushed the eopc/amendments-and-fixes branch from 68f125b to c33f99f Compare November 11, 2023 00:43
eopXD added 16 commits November 10, 2023 16:51
Extracted reference as a separate adoc file.

Signed-off-by: eop Chen <eop.chen@sifive.com>
Define (non-segment/segment) load/store intrinsics for bfloat16 values
and also psuedo utility functions for manipulation across types.

Signed-off-by: eop Chen <eop.chen@sifive.com>
Signed-off-by: eop Chen <eop.chen@sifive.com>
vfncvtbf16.f.f.w vd, vs2, vm
vfwcvtbf16.f.f.v vd, vs2, vm
vfwmaccbf16.vv vd, vs1, vs2, vm
vfwmaccbf16.vf vd, rs1, vs2, vm
…types

Signed-off-by: eop Chen <eop.chen@sifive.com>
Signed-off-by: eop Chen <eop.chen@sifive.com>
Signed-off-by: eop Chen <eop.chen@sifive.com>
@eopXD
Copy link
Collaborator Author

eopXD commented Nov 11, 2023

Rebase and addressed comments from @dzaima, thank you for pointing this out.
@kito-cheng I'll leave it to you to add some descriptions somewhere in the C api document and we'll then cite them here.

Copy link
Collaborator

@rofirrim rofirrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @eopXD !

@4vtomat
Copy link
Collaborator

4vtomat commented Apr 23, 2024

I'll take over and proceed this patch!

@4vtomat 4vtomat self-requested a review April 23, 2024 16:59
4vtomat added a commit to llvm/llvm-project that referenced this pull request Apr 23, 2024
@@ -0,0 +1,67 @@
== References
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this file does not look bf16 specific. Only the last line is bf16. How did the references work before?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this was separated out of rvv-intrinsic-spec.adoc. I just hadn't gotten there yet.

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@4vtomat 4vtomat merged commit 8278708 into eopc/amendments-and-fixes May 21, 2024
5 of 9 checks passed
@4vtomat 4vtomat deleted the eopc/bfloat16 branch May 21, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants