This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add type aliases float16_t, float32_t and float64_t
Changes PlannedPublic

Authored by wangpc on May 17 2022, 5:02 AM.

Details

Summary

We use them in RVV intrinsics doc but there is no definition
in riscv_vector.h, which is confusing for users. This matches
what GCC does too.

There are too many tests using the raw types, so we keep them
untouched.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 5:02 AM
pcwang-thead requested review of this revision.May 17 2022, 5:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 5:02 AM
asb added a comment.May 17 2022, 8:01 AM

Thanks for the patch - can you add test coverage for this please?

Add a test to check RVV type aliases.

pcwang-thead added a comment.EditedMay 18 2022, 1:49 AM

Besides, should we add vread_csr and vwrite_csr like what in GCC?
These two functions don't exist in RVV intrinsics doc Found it! Read/Write URW vector CSRs, is it a historical problem?

Move to separate RVVHeader.

I think we have no consensus in https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/18#issuecomment-817890161, and most people disagree the current naming,
maybe we need to have more followup discussion before landing this patch.

For example, maybe _Float16 should be supported when enable zvh, not zvfh?

I think we have no consensus in https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/18#issuecomment-817890161, and most people disagree the current naming,
maybe we need to have more followup discussion before landing this patch.

Thanks for your reminding of previous discussion!
Should we put this in next sync-up discussion agenda and settle it down? There are already some large code bases based GCC implementation, we should make it stable before it becomes too hard to change.

For example, maybe _Float16 should be supported when enable zvh, not zvfh?

You mean zfh? float16_t is only used in RVV intrinsics, so I think it is OK to me. And it is the same as generated type aliases in riscv_vector.h(at about line 130):

#if defined(__riscv_zvfh)
typedef __rvv_float16mf4_t vfloat16mf4_t;
typedef __rvv_float16mf2_t vfloat16mf2_t;
typedef __rvv_float16m1_t vfloat16m1_t;
typedef __rvv_float16m2_t vfloat16m2_t;
typedef __rvv_float16m4_t vfloat16m4_t;
typedef __rvv_float16m8_t vfloat16m8_t;
#endif

I think we have no consensus in https://github.com/riscv-non-isa/rvv-intrinsic-doc/issues/18#issuecomment-817890161, and most people disagree the current naming,
maybe we need to have more followup discussion before landing this patch.

Thanks for your reminding of previous discussion!
Should we put this in next sync-up discussion agenda and settle it down? There are already some large code bases based GCC implementation, we should make it stable before it becomes too hard to change.

I think so. But I think maybe we need to raise an issue somewhere (maybe riscv-c-api-doc) to gather opinions from community first. (see below)

For example, maybe _Float16 should be supported when enable zvh, not zvfh?

You mean zfh? float16_t is only used in RVV intrinsics, so I think it is OK to me. And it is the same as generated type aliases in riscv_vector.h(at about line 130):

Yes, sorry for my typo.

I think maybe we need to have more comprehensive consideration about define floating type aliases in RISC-V world.
For example, before RISC-V support half floating type, we had posted https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/172 to update the spec for half floating-point type.

or like https://github.com/riscv-non-isa/riscv-c-api-doc/pull/25, it's trying to define a unified naming rules for all intrinsics.
so I think maybe we also need to have RFC in riscv-c-api-doc to define the convention for floating type aliases.

#if defined(__riscv_zvfh)
typedef __rvv_float16mf4_t vfloat16mf4_t;
typedef __rvv_float16mf2_t vfloat16mf2_t;
typedef __rvv_float16m1_t vfloat16m1_t;
typedef __rvv_float16m2_t vfloat16m2_t;
typedef __rvv_float16m4_t vfloat16m4_t;
typedef __rvv_float16m8_t vfloat16m8_t;
#endif
evandro removed a subscriber: evandro.Jun 12 2023, 2:25 PM
wangpc commandeered this revision.Jul 13 2023, 7:51 PM
wangpc added a reviewer: pcwang-thead.
wangpc removed a reviewer: pcwang-thead.
asb added a reviewer: eopXD.Jul 14 2023, 7:46 AM

Adding eop as a reviewer.

Sorry for the late reply, I missed this in may mails.

I see that the motivation start from where you spotted this type alias. However it was essentially just an act for convenience so we don't have to map a more irregular pattern of ( _Float16, float, double) when generating the test cases by code. Is it necessary that we have them in the header? On the other hand, these are scalar floating-point types, and if we want them to be defined, I agree with Zakk that starting a discussion in riscv-c-api will be helpful.

wangpc planned changes to this revision.Jul 19 2023, 12:11 AM

I don't have any thoughts on this patch now.

Sorry for the late reply, I missed this in may mails.

I see that the motivation start from where you spotted this type alias. However it was essentially just an act for convenience so we don't have to map a more irregular pattern of ( _Float16, float, double) when generating the test cases by code. Is it necessary that we have them in the header? On the other hand, these are scalar floating-point types, and if we want them to be defined, I agree with Zakk that starting a discussion in riscv-c-api will be helpful.

Yeah, I agree. But I won't continue this now.