-
Notifications
You must be signed in to change notification settings - Fork 90
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
Public Review: __riscv_v_intrinsic
needs to be defined and <riscv_vector.h>
available reguardless of -march
to allow intrinsic usage in __attribute__((target("arch=+v")))
functions
#376
Comments
Thanks for raising this. We strongly support __riscv_v_intrinsic for detecting compiler support, plus being able to include riscv_vector without -march, plus allowing target pragmas to replace -march. These features will help RISC-V adoption by enabling binaries that work on CPUs regardless of its V support. Without them, users would have to recompile for the particular CPU, which is a non-starter in a server/cloud context. |
@camel-cdr So my reading from your proposal above is that we'd like to have |
Exactly, and you should be able to include |
I think we can now include |
When we last checked, this was not working yet: Seems dzaima's repro is still not working? https://godbolt.org/z/ndTf1YM6M |
@kito-cheng @4vtomat I think there is value in having this for 1.0. Do you think we can aim at it? If not I guess we could potpone it for a later revision of the spec. |
Yeah, I think it worth to make this change into 1.0 :) |
Oh, I mean you can include |
:) Yes, though a few other things are required for the use case (runtime dispatch) to actually work :) |
It might be worth adding something like "The supported architecture is specified to the compiler globally using the -march option, or the on a per-function basis using the |
This macro is used to check if compiler supports RVV intrinsics, so it should be defined no matter vector is enabled or not. Resolved riscv-non-isa/rvv-intrinsic-doc#376
This macro is used to check if compiler supports RVV intrinsics, so it should be defined no matter vector is enabled or not. Resolved riscv-non-isa/rvv-intrinsic-doc#376
A very common pattern in intrinsics usage is specializing functions for a specific ISA extension and implementing runtime dispatch.
This means that you can't globally defined
-march
to include support for the "V" extension, buy you rather use__attribute__((target("arch=+v")))
on the functions you specifically optimize with intrinsics and runtime dispatch.The current definitions of
<riscv_vector.h>
and__riscv_v_intrinsic
are unclear and thus currently unusable for a lot of libraries using this paradigm.It's ambiguous whether this can be interpreted as
__riscv_v_intrinsic
should be defined when compiling for the "V" extension (V is in march), or__riscv_v_intrinsic
should be defined if the compiler support the "V" intrinsics.Both clang and gcc interpret it to mean the former, so you can't use
__riscv_v_intrinsic
to detect support for "V" intrinsics: https://godbolt.org/z/EMbYYrr5YAgain, it's unclear whether including
<riscv_vector.h>
is supposed to work whenmarch
doesn't include support for a subset of the vector extension.But, both gcc and clang support including
<riscv_vector.h>
when it's not specified in march, such that it can be used in__attribute__((target("arch=+v")))
code: https://godbolt.org/z/oMrY4xn75I think both definitions should make it explicit, that
__riscv_v_intrinsic
shall be defined and<riscv_vector.h>
available regardless of-march
to allow intrinsic usage in__attribute__((target("arch=+v")))
functions.The text was updated successfully, but these errors were encountered: