RISC-V: They Should Have Known Better
52 points by dmitrygr
52 points by dmitrygr
This is refreshing.
I am a casual emulator author, and I was surprised with how annoying implementing RISC-V was. Just decoding instructions is such a pain. Of course, it only got worse when I tried to do ARM, and x86 is worse than that.
So would you characterise RISC-V being the easiest to decode of these popular architectures?
PowerPC and Alpha stomp all over it.
You can tell the RISC-V folks never bothered with silly things like actually implementing the system on an FPGA before making decisions. Store Register with Offset is egregiously painful on a small, in-order system as you need a full extra pipeline phase solely for this instruction if your memories are edge clocked. But the only things the RISC-V care at all about are super-pipelined, speculative execution A-Series competitors. Be as good as or better than an M0? Oh, hell, no. Can't be bothered.
You can tell the RISC-V folks never bothered with silly things like actually implementing the system on an FPGA before making decisions.
Which is completely incorrect.
The ISA, the toolchain, and implementations (both FPGA and actual test chips) were co-designed and repeatedly iterated and improved and incompatible changes made.
RISC-V is probably the only major ISA that was iterated with real-world experience before being frozen.
This whole thread makes me super depressed. People complaining about being ignored or booted out from a community and blaming it on that community's technical incompetence or NIMBYism for their social rejection. No self-reflection about why it might be the case that others got tired of (re)explaining things to them.
You can tell the RISC-V folks never bothered with silly things like actually implementing the system on an FPGA before making decisions.
That's a bold thing to say about the inventors of the RISC architecture.
They did actually implement the system on an FPGA, but only once. A significant amount of the RISC-V architecture is informed by the superscalar, in-order design of boom.
AIUI BOOM was the second design, there was an earlier single-issue in-order design series called Raven which was made on custom silicon https://thechipletter.substack.com/p/risc-v-part-1-origins-and-architecture
That article quotes their design motivation, “a new RISC ISA can be better than its predecessors by learning from their mistakes”, but evidently they repeated the mistakes of “Leaving out too much” and “Allowing current micro-architectural designs to affect the ISA” (the early design was over-fitted for making it easy for undergraduates to write a simple decoder in Chisel as a student project).
Store Register with Offset is egregiously painful on a small, in-order system as you need a full extra pipeline phase solely for this instruction
Be as good as or better than an M0?
Could you explain the store issue a bit? As far as I can tell, M0 and RISCV are identical here?
M0:
STR, STRB and STRH instructions store the word, least-significant byte or lower halfword contained in the single register specified by Rt in to memory. The memory address to load from or store to is the sum of the value in the register specified by either Rn or SP and the immediate value imm.
RISCV (is there really no convenient web index of instructions? TT):
The effective address is obtained by adding register rs1 to the sign-extended 12-bit offset. Loads copy a value from memory to register rd. Stores copy the value in register rs2 to memory.
They did implement on FPGA, but that’s part of the problem. They had an FPGA implementation and an immature GCC port and used this as the input to a lot of decisions. For example, the article complains about the immmediates scattered all over the place. This was done so that the source operands were known prior to decode, which let you do register fetch before decode. And that is really nice for small in-order cores.
It stops being as useful when you start having floating-point instructions because you know which register to fetch but not which register file to fetch it from.
For superscalar chips, you want to do this post decode because you don’t want false positives in keeping rename registers alive: that will hurt performance more than any decode speedup possibly could.
Even by the time you have dual issue, this property isn’t very useful. But they overfitted for the simple in-order core. All you’re left with is overhead in routing from pulling bits from different parts and running them together. This isn’t an enormous overhead and is normally drowned out by something else.
This also shows up in the C extension. It’s designed so that a simple core can expand every 16-bit instruction to a 32-bit instruction. That lets you add it in the decode stage without any modifications to later stages in the pipeline. And, yes, that does help. In simple, in-order cores.
But for big out-of-order cores, the thing that matters most is the amount of work done per instruction. You have a lot of fixed overheads in fetch, decode, instruction scheduling, register rename, and so on that you want to amortise those costs over larger amounts of work. Rich addressing modes are the obvious win here because doing a bit of arithmetic in a load-store pipeline is basically free, doing two instructions means you calculate the address twice. When this was pointed out early on in RISC-V, Krste kept asserting that instruction fusion (decoding two or more instructions as something that you execute as one) would solve all if those problems. This was never true: instruction fusion is hard, is even harder when trying to fuse instructions across fetch granules, and it means you’ve defined a per-implementation variable-length instruction encoding that compilers have to know about.
The article overstates the cost of decoding variable-length ISAs. I worked on an ISA designed for server cores that used a variable-length encoding and the decoder didn’t show up as a problem in any of the evaluation. And it let us put a load of things in 48-bit instructions, so the 16-bit instruction subset covered well over 50% of dynamic instruction counts. Instructions for system calls and instructions that are usable only in privileged modes were all 48 or 64 bits, so they didn’t eat any of the shorter encoding space.
Yes, but way worse than 6502, Z80, and MIPS.
It's been a while, but: 6502 was only easy because of its tiny instruction set and tiny set of registers; it was pretty frustrating for me. Z80 was actually elegant. (I had a Z80 on a card in an Apple ][+ back in the 80s.)
And Motorola is the only company who consistently designed nice ISAs. Unfortunately, I never really got to use theirs.
Z80 was my favourite until I met 68K. Then I met x86 and stopped doing assembly language altogether.
I am working on being more polite with my words, but this article is a real struggle given the author's attitude. RISC-V was designed by academics and industry veterans with decades of experience. They certainly knew better than the OP.
Complaining about modularity is the thing that makes it so RISC-V doesn't carve mistakes in stone forever, like the proprietary ISAs do. While standard profiles must go through a committee of actual implementers, the modularity OP is complaining about makes it so anyone who has a need for a different set of instructions (including proprietary ones) can do so. Qualcomm did this while developing some silicon and proposed changes. The committee thinks it's a good idea, so those changes will probably go into a future version.
The OP is free to make their own profile and very much encouraged to try and make it a standard! Instead they argue that the only reason the inventors of RISC didn't adopt their preferred open ISA is NIMBYism. This rant is like an undergrad getting frustrated with their homework and calling the professor and authors of the textbook stupid.
While I'm saddened to see it getting voted up so much on Lobsters and elsewhere, the community is pretty burnt out re-explaining this stuff to the non-curious. I'll update this comment if we get around to creating a FAQ for this type of content on the r/riscv wiki.
There is no such thing as bad publicity. The only thing worse than being criticised is not being talked about or thought about at all.
Stroustrup was correct about the two kinds of programming languages.
It's all just a sign of how much we're winning.
The blog preempts this, but it is interesting that about half (but certainly no more) of the issues come from RISC-V not effectively supporting binary reuse across different processors. This definitely takes RISC-V out of contention for desktop computing—where binaries are the de-facto distribution format for software—without adding other standards on top. But it does feel like a defensible choice for a lot of use cases, especially if requiring a recompile can allow you to use simpler and more efficient processors.
Glad that you mention binaries as a de-facto distribution format being relevant to its adoption, because Gentoo seems to be providing good support for it
Some compare it to the times when amd64 was newish and Gentoo had a growing userbase of people atracted to how compatible it was with the it. Portage is already capable of managing the migration with little pain (relatively speaking, of course)
On the embedded front, having a custom chip is 100% the right thing to do and ARM's habit of dictating features when they aren't needed is an anti-feature for many. It's a one-off chip for a platform no one else uses, so saving every penny can reap millions in savings.
This isn't a desirable scenario when the number of users for a platform gets larger, so the RISC-V community created platform specs. This is a mechanism where vendors can coordinate on shared CPU classes with feature baselines. The Qualcomm's of the world will likely have the market share to force their own unique profile - but then it's up to them to provide tooling and upstream support.
The negative consequences of having choices is just the natural result of not having a monoculture. Windows and OS X are monopolies which can dictate the number of flavors available. People complain that "Linux" has too many options, as anyone can create new and slightly incompatible OS and everyone does. But that doesn't make Linux less suitable to create an OS with binary compatibility, as evidenced by vendors like Red Hat.
This increase in the number of variants is just the monopoly powers changing hands. x86 has the same problems between and within Intel, AMD, and various smaller x86 vendors (alive and dead). The mirage provided by proprietary monopoly providers was simpler, for sure, but it also stifled innovation and incentivised marketing driven ISA design.
I appreciate the point about openness. An open spec does very little to make implementations open, unfortunately. If mainstream desktop RISC-V CPUs ever come, there's a 90% chance that they will run closed source UEFI firmware, have hardware that requires executing ACPI bytecode blobs, have undocumented integrated management processors, etc...
And mainstream RISC-V SoCs and SBCs will have exactly the same issues as ARM, where there's not even something like UEFI; all SoCs have their own weird non standard boot process, all peripherals have to be hard coded into a device tree instead of discovered at runtime or provided through a standard interface.
People over-estimate the impact of ARM's closeness and the benefits of RV's openness while under-estimating the impact of Intel and AMD's commitment to making their chips run on standardised platforms which provide way, way more than just an ISA.
I love RV myself, I like that there's an ISA with good compiler support which is both simple enough that I'm able to implement it myself (as I did in Logisim once) and open enough that I'm allowed to do that. But the end user impact is negligible. Is anything, it's worse because ARM has at least made an attempt at standardising an ARM server platform; I don't really trust that the RC foundation will do the same.
ARM has at least made an attempt at standardising an ARM server platform; I don't really trust that the RC foundation will do the same.
Already done and ratified and published.
I think it’s good to critique RISC-V’s design constructively, but the tone of this post made me feel sad and wanting to stop reading.
It’s a free and open design made by passionate people, and everybody is invited to contribute. I don’t think phrases like “embarrassment” and “you can tell the authors are academics” are justified.
Sorry to tone-police here, you’re obviously welcome to rant however you like on a personal blog. I do think the fact that RISC-V exists at all is a miracle, though, and we should be kinder to everyone who made it possible. It’s not being forced on us, people will use it if it works.
It’s a free and open design made by passionate people, and everybody is invited to contribute.
That is not what I've heard from people who've tried to contribute but don't agree on everything with the original designers and SiFive.
People have critiqued the design of RISC-V since it started to exist, and it's always been "sod off, we do things the RISC way here!" not "oh, please help us make it better".
Counter: openSparc and openRISC exist and RV is not a miracle since it doesn’t improve on those significantly.
Do they actually exist, as in, you can go on aliexpress and order a dev board?
They obviously would, if they had the publicity that instead got to RISC-V.
That's a "no" then
Popularising an ISA is a lot of work. RISC-V did the work, it's not their fault others didn't.
RISC-V was an internal project at a university. They only started thinking about turning it into an industry standard when industry folks started asking why they had revised the ISA. So industry people went out and used it for IRL hardware before it was a standard.
It certainly wasn't "publicity" that made the difference here, as they didn't have an advertising budget. openSparc, openRISC, and open MIPS all died because RISC-V was better. MIPS might have had a chance if they had opened up early on, or at least not tried to charge the RISC-V authors to use it.
They were all inferior and the proof is that MIPS is a RISC-V design shop now.
Some of the creators of those chips disagree. Strongly. The former CTO of Sun certainly thinks RISC-V is an improvement on SPARC.
The severity of the findings more than justify the tone in my opinion.
I’m not so sure… The author has clearly thought a lot about these problems and their findings could stand up on their own merits.
Obviously it’s okay to vent your frustrations, but the mocking and ridicule sets off alarms in my brain that it’s making up for a weaker argument by diminishing the RISC-V designers. I don’t see evidence that the RISC-V folks have been outright malicious enough to deserve that.
Yeah agreed! I found the technical critique really interesting and insightful, but sometimes it felt a bit mean spirited
There’s a lot of creative invective here that makes me wish I understood the ISA details better so that I could appreciate it even more.