-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
proposal: cmd/compile: add support for RISC-V B-extension #47373
Comments
Supporting assembly seems fine.
Where are the minimum extensions for riscv64 specified? I don't see an entry in https://github.com/golang/go/wiki/MinimumRequirements . Could you add an entry? Yes, we can't use B extension instructions in the compiler without introducing a GORISCV64 environment variable or guarding them at runtime. |
I have added, that the minimal requirement is rv64g (rv64imafd).
I suggest using a GORISCV64 environment, and gcc/clang use the command line option -march to indicate instruction set. |
One more reason for support a GORISCV64 env-var, is that there might be rv64 machines without a HW floating point unit. All FP calculation must be implemented via software functions. For example, we reqiure the minimal should be I-M-A, and F-D-B-V-P are optional. So the GORISCV64 is a combination of F-D-B-V-P with a prefix IMA. |
I think we should detect extension in runtime cpu feature detection. |
This proposal has been added to the active column of the proposals project |
While there is no significant downside to adding support for these instructions in the assembler, I also think there is benefit in waiting until there is actual hardware support for them. Furthermore, we should be confirming that the use of these instructions is actually providing benefit, which means we need to be able to benchmark. IMO as far as possible we should avoid compile time options and perform runtime detection - I've seen various problems with compile time options (like Lastly, the current Go riscv64 port currently targets |
It sounds like we should decline this issue until there is actual hardware that we can use to measure the impact of B. There was a suggestion above to lower the current minimum feature set, removing F and D. That is a separate discussion, and if you feel strongly about that, I would suggest filing a separate proposal. |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
There is realworld riscv64 hardware supporting the B extension, https://www.sifive.com/cores/u74 and we can buy a dev-board from https://www.iceasy.com/10210/1022688923.shtml Do we consider that
|
ping ... Any further conclusion about support the B-type instruction set. |
Moving this back to the incoming proposal queue. |
The GORISCV64 variable would match all the others. The list should probably be comma-separated instead of assuming single-letter feature names. For GOAMD64 we managed to use v1, v2, v3 etc. Is there anything like that in the RISC-V world, or do we need a full feature enumeration? And I assume that our minimum required set would be implicitly required still, no matter what GORISCV64 says? |
This proposal has been added to the active column of the proposals project |
I advocate your idea, that using comma seperated features. AFAIK, there is a
|
There is also real HW support half floating point scala, whose name is |
I did not find a real world riscv64 HW that has not the F & D extension, so I suggest the minimal to be |
While I think we are closer to being able to support the B-extension, I believe a prerequisite is having a builder that supports these instructions (neither of the current builders do). It is also worth noting that the suggested hardware is likely to be have lower performance (2 cores) than the current builders (8 cores). Also, to reiterate my previous comment, as far as possible, we should avoid compile time options and perform runtime detection instead - otherwise there are a number of cases where the lowest common denominator has to be assumed. |
Because of the way that ISA extensions have been approached, it is theoretically possible to build a CPU that has the minimum extensions, all of the extensions or some combination of the extensions (hence full enumeration would be needed). That said, there are already groups like
We would either need to add |
We have a baseline of 'g' and I don't think anyone is suggesting we abandon that. So we don't need to say 'g' explicitly in the GORISCV64 list. (We could use This issue is just about "is it okay to support GORISCV64=b?" It seems like the answer should be yes. For operations like bits.CountLeadingZeros which are probably a single cycle when you just emit the direct instruction, it's hard to see how any kind of runtime feature detection wouldn't be a huge performance loss. |
As you suggested, if |
The new hardware does have poor performance to become a build machine. So we can support it in the assembler first without a builder. And then we make use of
|
So apparently the Starfive VisionFive board does not support the B extensions (even though it has U74 cores) - the specification on the allnetchina website (and others) only lists |
It was suggested previously, but has since been retracted.
I was not suggesting it be required explicitly in
I agree in general, however without real world hardware existing and at least one of the builders supporting this extension, I doubt we can reasonably proceed beyond assembler support.
Correct, there are going to be situations like this that cannot be avoided - again though, the problem is that for any situation where binary packages are being built for distribution, the lowest common denominator has to be assumed, meaning that no one benefits from these extensions in these cases. |
Change https://go.dev/cl/394435 mentions this issue: |
I will buy this board and verify if the B instructions can run normally. |
I have consult my friends who has this dev-board, he confirmed that several B instructions such andn,orc,bclr would cause illegal instruction exception. So I will close this proposal, sorry for bothering. The SiFive's website misguide me. |
Hi, U74 does not support full B instructions, actually U74 only support zba and zbb instructions as stated in the U74 complex manual. I bought a Starfive VisionFive2 board which has quad u74 cores. I verified that both zba and zbb instructions can work correctly, but zbc and zbs instructions will cause a SIGILL. |
You can implement zba and zbb first, and do some tiny optimizations like this, |
I mailed https://go.dev/cl/461143, https://go.dev/cl/461144. I will try to do some optimizations and run benchmarks on dev board. |
The specification of bitmanip instructions became stable from draft: https://github.com/riscv/riscv-bitmanip
So I propose to support these instructions, which could make following benefits.
However, there is no real world hardware support them now, but we can implement them in the assmbler by now.
One concern, Go's riscv64 implies the i-a-m-f-d extensions (also known as rv64g ), do we need something like GORISCV64=GB to enable the B-extension instrutions?
The text was updated successfully, but these errors were encountered: