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

[NEON] to SVE fallback #914

Closed
XXYYZZss opened this issue Sep 24, 2021 · 2 comments
Closed

[NEON] to SVE fallback #914

XXYYZZss opened this issue Sep 24, 2021 · 2 comments

Comments

@XXYYZZss
Copy link

Hi All,

I'm interested in adding ARM SVE fallback for NEON.
But, SVE's intrinsic accepts sizeless data types which can't be put into union type such as simde_float32x4_private.
Any comment for the least effort to solve this issue without changing existing code.

Thanks all.

@nemequ
Copy link
Member

nemequ commented Sep 25, 2021

To be clear, are you talking about implementing NEON using SVE, or SVE using NEON? The former isn't necessary; SVE implies NEON support. For the latter, we already have the beginnings of some support for SVE… it's more of a proof-of-concept at this point and is nowhere near usable (and I currently don't have time to work on it), but several functions are implemented and work fairly well (better on some compilers than others) so I think the concept is sane. Basically:

The important thing to remember is that SVE is designed to be scalable to any vector width which is a multiple of 128 bits up to 2048 bits. Software can't make any assumptions about what size the underlying hardware uses, so SIMDe just emulates a 128 bit implementation of SVE (or, if the user has AVX2 we'll use 256-bit vectors, and if they have AVX-512 we'll use 512-bit vectors). As long as all the APIs return the right values (e.g., svcntb() must return sizeof(int8x16_t), svcntw() must return sizeof(int64x2_t) / sizeof(int64_t), etc.) everything should generally work.

SVE's C API is interesting in that a lot of what makes SVE special at the C level are actually restrictions not enhancements. For example, you can't use the sizeof operator on sizeless types. That's not really a problem for SIMDe... those types won't really be sizeless and sizeof will work on them, but that doesn't really matter if you don't use it. A lot of functions will return compile-time constants (including svcntb(), svcntw(), etc.), but that just means they often get optimized away by the compiler.

If, on the other hand, you were talking about using SVE to implement NEON, things are a bit simpler. All of the operations in SVE are predicated so you can just mask off everything but 128 bits (or 64 bits if you want to support 64-bit operations).

@XXYYZZss
Copy link
Author

XXYYZZss commented Sep 26, 2021

@nemequ Thanks for the reply.

I'm talking about implementing NEON using SVE or RISC-V RVV extension whose data type is sizeless.
I've traced the implementation, all general scalar implementation must transform to a union data structure (e.g., simde_float32x4_private).
The problem is this design can't support sizeless data types. Those types can't be put into the union structure or be passed to a sizeof function.

I've internal implementation which can support the above fallbacks, but I need your comment on how to deal with this situation so that I can merge into the upstream implementation.

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

No branches or pull requests

2 participants