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

Using vector intrinsics with __attribute__((target("arch=+v"))) #69

Open
camel-cdr opened this issue Feb 21, 2024 · 4 comments
Open

Using vector intrinsics with __attribute__((target("arch=+v"))) #69

camel-cdr opened this issue Feb 21, 2024 · 4 comments

Comments

@camel-cdr
Copy link

It is currently not possible (on gcc and clang) to use the vector intrinsics in functions with a target attribute that adds vector support, if it vector support wasn't also enabled globally.

This is needed for implementing dynamic dispatch in the same translation unit, as e.g. used in simdutf.

The current compiler implementations aren't wrong to only allow including <riscv_vector.h> and defining __riscv_v_intrinsic, when the vector extension is enabled globally, but I think we should encourage implementations to view __riscv_v_intrinsic and __riscv_vector separately, when possible.

Something along the lines of "__riscv_v_intrinsic being defined doesn't guarantee that __riscv_vector is also defined."

From what I can tell this isn't required by the spec anywhere, but implementers assumed the opposite is implied.

The __riscv_v_intrinsic macro is the C macro to test the compiler’s support for the RISC-V "V" extension intrinsics

__riscv_vector [...] Implies that any of the vector extensions (v or zve*) is available

This would suggest, that __riscv_v_intrinsic does not automatically imply __riscv_vector is defined.

@topperc
Copy link
Contributor

topperc commented Feb 21, 2024

For clang this needs a lot of work. For example, the code in SemaChecking.cpp that checks for valid rvv vector types is completely unaware of the existence of attribute((target)).

@camel-cdr
Copy link
Author

Alright, good to know, I was wondering if it might just be harder to implement.
It's not a really high priority thing.

@kito-cheng
Copy link
Collaborator

We (SiFive) have assigned engineer resource on clang side, and will try to find people to enable that on gcc side :)

@4vtomat
Copy link

4vtomat commented Mar 2, 2024

I have a PR for this: llvm/llvm-project#83674.

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

4 participants