-
Notifications
You must be signed in to change notification settings - Fork 203
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
Add an arch for RISCV with vector extension #625
Conversation
Signed-off-by: Michael Roe <[email protected]>
It would be cool porting Volk on RVV |
I'd be in favor of adding RiscV support for VOLK. Also, we already run QA tests for RiscV and we already have some hand optimized assembly for this ISA. Though, no vector support for it. This PR in particular is difficult though because |
RISC-V Vector v1.0 (RVV1) looks like perfect fit for Volk. |
Is |
RISC-V has naming convention (ISA-string) described in the spec: I think the baseline Vector ISA for this project should be C++ compilers will take this string as |
The GCC RISC-V architecture options imply that we could optimize for any given CPU. That'd be to many machines to compile, I assume. gcc -march=rv64i2p0m2p0a2p0f2p0d2p0v1p0 While I assume the clang argument is: clang -march=rv64i2p0m2p0a2p0f2p0d2p0v1p0 I was hoping for smth like gcc -march=rv64imafdv I read that there are some names for a common set of extensions. This might be interesting as a baseline as well. |
You are right. The are some baselines like rv64g
|
Another related question is: Are we using ASM or Intrinsics ? |
I suggest to use intrinsics. So far, we mostly use intrinsics and only rarely use ASM. Also, we tend to replace the ASM code with intrinsics when they're available. If a platform comes with Vector extensions, is it reasonable to assume it comes with m,a,c too? If we decide to make this optional, we will eventually see situations where we have to work around this assumption. I'd like to keep things simple. Would you be willing to set up an initial environment? I'd envision 2 options:
Currently, we use: https://github.com/uraimo/run-on-arch-action#supported-platforms for non-x86 platforms. If we can integrate a CI test for these machines, that'd be worthwhile. As soon as we set up the initial machines and CI, we can start to add optimized kernels. It'd be interesting to see how well a compiler optimizes code compared to hand-optimized kernels. |
I can setup CI for:
I can setup cycle-accurate model benchmarking ~100KHz simulation speed. |
Just an update. A board with a RVV 1.0 capable CPU has been released. The Banana Pi BPI-F3. https://docs.banana-pi.org/en/BPI-F3/BananaPi_BPI-F3 Current boards only have 4GB of RAM, so it may be better to wait for 8 or 16GB models to come out. |
Ok, various other peo0ple have expressed an interest in using RISC-V vector extensions with volk. I can amend this PR, but …. What doyou guys really want it to do? Getting cpu_features to just check for “v” is easy - I already upstreamed a patch to cpu_features to do that. Checking the parameters of the vector extension (size of registers etc) might be harder. |
@michael-roe multiple things.
In most cases, we rely on compiler switches to produce the best optimized version for a specific set of vector extensions. e.g. for SSE4, we compile a machine with |
Here's a good article on RVV intrinsics. https://fprox.substack.com/p/risc-v-vector-programming-in-c-with The example code could be the basis for the first kernel.
|
For example, what would you like the (volk) machines to be called? Which features does the vector machine require? 64 bit? Check for “v” in the option string to detect the presence of vector instructions. (Rather than something more complex involving e.g. finding out what size the vector registers are). you probably already know that, but typically the Riscv option string is in the Flattened Device Tree (FDT), which gets parsed by the kernel, which then gets queried from user space by cpu_features. |
Seems like everyone is calling it "rvv". You'll probably want to check the compiler version (for gcc, 13 or later). hwprobe has been added for Linux 6.4. Here's the example code.
On HiFive Unmatched:
On VisionFive 2:
I'd think kernels could be vector size agnostic. |
We could call the machine something like rva22u64v (ie rva2264u profile, with the optional vector extension). semantics would be as per the riscv profile, so it would also include the bit manipulation instructions. |
Also, because the rva22u64 profile says to implement all of V rather than some subset of you’re going to implement it at all, that gives us some justification for just checking for “v” rather than some subset of the vector Isa. |
It looks like if I turn my back for a minute those wacky riscv guys will have added a bunch of new instructions… in particular, we now have the Zfa extension, which on a 32 bit platform includes fmvh.x.d, which lets you get at the upper 32 bits of a double precision floating point register. I’ve got to admit, I really wanted this instruction. (MIPS had the equivalent instruction). |
If there's a certain set of instructions that are required to be implemented as a whole, I'd summarize this with 1 abbreviation. If this is A side note: I doubt that we need support for RiscV for anything but Linux at the moment (and maybe, maybe *BSD at some point). |
There’s a recent PR (#774 I think) that will probably make this one obsolete. I’ll close this one when/it we’ve merged a change that supercedes it. |
Obsoleted by #774 |
No description provided.