Top
Best
New

Posted by dmitrygr 2 days ago

RISC-V: They Should Have Known Better(dmitry.gr)
328 points | 376 commentspage 4
artemonster 1 hour ago|
"What range of offsets can a 16-bit instruction encode? Zero through three. Not thirty three, not three hundred and three. Three! Well, maybe it is better for storing a halfword? Nope... zero or two. What even? Why" What the fuck is this criticism? Its sanely specced, who would want arbitrary unaligned offsets, like for anything? Supporting such obscure idiot cases is too much unnecessary pain, so cut it off on spec level
mappu 1 day ago||
RVA23 hardware is available (e.g. SpacemiT K3)
Joel_Mckay 1 day ago|
Some are already on RVA23.1 even before the standard made it to more than 4 manufacturers product lines.

The meme joke about standards is sadly relevant for riscv. =3

https://xkcd.com/927/

d-us-vb 1 day ago|||
As I’ve come to understand it, standards simplify intensionally, not extensionally. For those who select a part that is compliant with a standard, more standards to choose from is better because engineers are able to make better tradeoffs; they’re not forced to select a part that does way more than the application needs thus making the product more expensive if there are lots of “competing” standards: some do less some do more.

For RV, a litany of standardized modules creates a system where each capability that the module provides will have a standard interface. No manufacturer is forced to invent extensions bespoke to their implementation, but they’re not forced to support everything the most powerful models do either.

Just my two cents.

ngl999 1 day ago||
That is given, vendors actually _know_ what exact practical applications they are building for.
Joel_Mckay 1 day ago||
Sure, the constellation of features is no longer a general purpose computer in the retail context, but rather an ASIC appliance the ends up incompatible/useless rather quickly.

Maybe Gentoo could tame that level of chaos... or people just buy ARM64 again knowing the software ecosystem already works. =3

camel-cdr 1 day ago|||
The RVA point releases don't add new mandatory features, so every RVA23 complient board is also RVA23.1 complient. They only add new optional extensions.
Joel_Mckay 1 day ago||
Until people admit they made the same mistake as ARM6 fragmenting the architecture focus, its adoption will probably continue to stall under each firms hubris. =3

https://en.wikipedia.org/wiki/Second-system_effect

unfocso 15 hours ago||
Refreshing style of writing. I know nothing about ISAs, but the rant was so fun
exmadscientist 1 day ago||
> After being asked for the Nth time to explain, I decided to put it all down in one place so that I could simply link to it when asked next.

Bookmarked, because I've needed the same.

The worst part of all this is that they really should have known better by now. In 1980 you could make these kinds of mistakes, because this was pretty new territory. In 2020, doing this just makes you stupid. Or ignorant. Or both.

NetMageSCW 1 day ago|
I’m not so sure - the 6502 existed in 1980 and showed the way.
bsder 1 day ago||
6809 is a better exemplar, but, yeah, we knew this stuff way back when.

The problem is that everybody around RISC-V wants to sell IP instead of a chip. Most of the worst brain damage follows from that.

The rest of the brain damage follows from "We want to compete with ARM A-Series cores." No. Just ... no. Nobody willing to spend that much on a processor gives one iota of damn about ARM licensing fees.

So, the semiconductor market wants a cheap, consistent chip that operates in the deep embedded space while the RISC-V ecosystem considers the mere thought of that to be icky beyond reason. And China will push on this like Longsoon and pray that somebody figures out how to make it not suck (Prediction: they won't succeed.)

And, the worst part is that RISC-V has basically lost its window. The single possible advantage that RISC-V had was that as people converged to a shared tooling ecosystem it would create lockout. Unfortunately, that convergence never happened so, at best, we got some shared compilers. And, now, AIs can basically one shot all your other tools around it and probably the compiler not far behind. And there goes your ecosystem lockout.

hn_submit 1 day ago||
Because selling "bits" is very lucrative, whilst actual hardware can lead to huge losses if it doesn't sell. Just ask Microsoft.

It's no wonder Microsoft is pulling out of the game console market and handing it over to PC manufacturers to make the actual hardware.

aappleby 19 hours ago||
Having written a few RISC-V cores, worked on a chip design project that used RISC-V cores, and generally being OK with the architecture in real-world use cases:

What the heck is this guy's problem? Just about every thing he mentioned as a problem is not a problem in practice. Too many options? Who cares, you're not trying to write code that runs on every possible configuration. Either you're writing embedded firmware and know exactly what core you're using, or you're writing an application that runs in an operating system and that system has a minimum ABI like RVA20 or whatever.

Array accesses take an extra instruction? Either you're in a tight loop walking a tiny array and you don't do the full offset calculation per step, or you're walking over an array in RAM and you're bottlenecked by the memory bus.

Hell, 90% of his arguments are "You can't detect X at runtime from user code without relying on some extension" - Yes, that is totally fine. Either you know your target CPU, or you don't - and then you ask your OS for details. This is not some dealbreaker.

From the article - "For example, if you are writing a kernel and want it to support all RISC-V cores" - NOBODY IS DOING THAT. You target a platform spec, not the combinatorial explosion of everything from RV32E to RVA22 or whatever the latest is.

You want to distinguish S mode from M mode? WHY DO YOU NOT ALREADY KNOW THIS?

Instruction encoding is weird? WHO CARES, the decoding is like eight lines of Verilog.

"Who can predict how their binary will act when a floating point store silently becomes a double-register move or a jump instruction, or vice-versa?" - THIS DOES NOT HAPPEN IN PRACTICE.

Guhhhhh, I don't get it. This guy has some vendetta and either has not shipped any risc-v code or is just in love with his own personal favorite instruction set.

wasmperson 17 hours ago||
> Array accesses take an extra instruction? Either you're in a tight loop walking a tiny array and you don't do the full offset calculation per step, or you're walking over an array in RAM and you're bottlenecked by the memory bus.

I'm not a hardware person, but whenever I look at compiler output I find computed index accesses all over the place in the assembly. This would suggest to me that at least compiler developers believe these addressing modes to be important.

> Yes, that is totally fine. Either you know your target CPU, or you don't - and then you ask your OS for details.

So then my code has to choose between being hardware-dependent or OS-dependent? That doesn't seem ideal.

> "For example, if you are writing a kernel and want it to support all RISC-V cores" - NOBODY IS DOING THAT.

I'd hate to live in a future where linux distros need to ship a separate kernel binary for every random combination of RISC-V features. That said maybe the run-time feature-detection extension will be so widely supported in practice that this wouldn't come up?

Lord-Jobo 19 hours ago|||
Yeah the OP post read to me like someone throwing the baby out with three drops of bath water. If this was presented more like “minor gripes with risc V” I’m guessing I wouldn’t feel that way
AlotOfReading 16 hours ago|||

     Either you're writing embedded firmware and know exactly what core you're using, or you're writing an application that runs in an operating system and that system has a minimum ABI like RVA20 or whatever.
It's very common for embedded teams these days to support a diverse set of cores with a shared codebase, depending on the specific requirements of different products/systems. SoC vendors will often change cores between versions or product lines, and I might need performance in this one system vs specific interfaces in another. So even if I know what core I'm using today, I don't know what core I'll be using in a year or five. I may also be writing a library or other reusable component and have no idea what core will run things today.

    Array accesses take an extra instruction? Either you're in a tight loop walking a tiny array and you don't do the full offset calculation per step, or you're walking over an array in RAM and you're bottlenecked by the memory bus.
Let's take the bitfield instructions the author complains about for similar reasons. If bfi/bfx takes multiple instructions, optimal structure packing isn't necessarily a win for performance or memory usage. The programmer needs to trade off how often the structure is instantiated vs accessed. Even they can make the right decision today, it might not be the right decision tomorrow. And if they get it wrong, that might not be apparent until later (when it will be somewhat obscured in superficial memory usage analysis). Or the ISA can get it right the first time and also make things easier for compilers/humans in the process.

    "Who can predict how their binary will act when a floating point store silently becomes a double-register move or a jump instruction, or vice-versa?" - THIS DOES NOT HAPPEN IN PRACTICE.
I can easily imagine this happening. When you change embedded platforms, the typical approach is to take the existing system and compile it for the new platform without carefully revisiting every decision made in the old system. If one of your vendor blobs was specified for the old system and the new system is "similar", you'll just link it in and see what happens. The metadata in the blob will hopefully catch the issue at link time, but it was an avoidable error.
wren6991 12 hours ago||
> If one of your vendor blobs was specified for the old system and the new system is "similar", you'll just link it in and see what happens.

And what if that blob has instructions your new core just doesn't implement? This problem has nothing to do with overlap.

summa_tech 57 minutes ago|||
Then you take an illegal instruction exception, and you have a choice to request a rebuild, patch it, or emulate it. (Yeah, sometimes the vendors just don't cooperate.)

Incidentally, emulating opcodes is quite often practical (unless the performance must not be affected), and is greatly helped by having the plainest, cleanest instruction encoding possible, and a well designed system register & exception architecture.

AlotOfReading 12 hours ago|||
Then it crashes in a nice, obvious way as soon as you execute one of them? Illegal instructions aren't usually that hard to debug unless they're related to memory safety issues.
therealcamino 18 hours ago|||
Thanks for this. RISC-V brings out the armchair critics for some reason.
bfrog 19 hours ago|||
The encoding being oddball does have some effects on linkers/loaders though I imagine?

Not that linking/loading is a super hot path people generally worry about.

aappleby 18 hours ago||
It has an effect only in terms of how big an offset you can encode in a relative jump, the _arrangement_ of those bits in the instruction is irrelevant (and already abstracted away in the compiler/linker framework).
dmitrygr 15 hours ago||
> NOBODY IS DOING THAT.

RePalm kernel is literally that.

IshKebab 1 day ago||
I think a lot of this criticism is completely true. However it's also overblown. I do think the ISA matters, but little mistakes like these definitely don't matter enough to preclude making M-series class chips. The reason it hasn't happened yet is simply time. It takes a really really long time to build up to that level of performance.

They've definitely gone overboard on the optionality stuff though. I don't think it matters too much for the actual CPU design but it makes verification and writing portable software a huge pain. Profiles definitely help but still...

Oh also I feel like you could probably come up with an equally compelling list about any other ISA. It's not like the fact that something has flaws means it's bad.

NetMageSCW 1 day ago||
I don’t think making optional what optional features are available is a little mistake. It is a torpedo to the waterline.
IshKebab 1 day ago||
It's not. In practice you have two scenarios:

1. You have a microcontroller. You're compiling code yourself and the docs tells you what features are available and which compiler flags to use.

2. You are writing application code. In that case you simply target RVA23.

The edge case is the same edge case where you use CPUID on x86, I.e. you want to target say RVA23 and RVA28 in the same binary. In that case you do have to use the OS APIs to discover what is supported... which is slightly annoying, but in practice you're just calling a different function.

In theory `mconfigptr` will eventually make this a lot nicer but nobody has put in the effort to define how it works yet (last I heard they were looking at ASN.1 sick emoji).

phire 1 day ago|||
Don't forget:

3. You are writing a kernel, with large amounts of inline assembly

4. You are writing a compiler, either offline or online

5. You are writing embeddable blobs that don't know what platform they will be running on.

6. You are designing a RISC-V core, and need to decide which extensions you should be supporting for your intended use-case.

wren6991 1 day ago||||
When I looked into mconfigptr some years ago I thought it looked like a swirling vortex of pain that might produce something useful some day. Good to see it's still being worked on. Sad to hear ASN.1 is still involved.

I added an "misa but more bits" register to my core, using the bit assignment from the RISC-V C API, so at least until then I know what extensions each instance of my core implements. https://wren.wtf/hazard3/doc/#reg-h3.misa

Linux folks seem to have already put a lot of the mconfigptr info into the DT blob anyways.

yjftsjthsd-h 1 day ago|||
> You are writing application code. In that case you simply target RVA23.

You're allowed to not handle a majority of extant Linux-capable machines, but it seems like an awkward position.

eek2121 1 day ago||
ALL chip designs are an exercise of minmaxing these 3 variables:

1) power

2) performance

3) die area

SOME chip designs also care about a 4th:

4) die area.

NO design has the best of all...it is impossible since you have to trade 1 for another. The reason x86 has been dominate for so long is that is strikes a good balance across all areas, especially #4. A good balance is what you need for a good chip.

EDIT: oh and you can't beat the system I mentioned above. The laws of physics are the reason why.

Tuna-Fish 1 day ago||
You forgot the variable that RISC-V chose to maximize:

5) Weird principles that are completely detached from anyone's actual needs and that are carried to a length similar to religious convictions.

My biggest personal pet peeve about the architecture is the JAL instruction.

That is, PC-relative jump and link immediate, which jumps to an PC + sign extended immediate value and stores the address of the next instruction in a register. This is your most basic function call instruction. It only has an immediate range of 21 bits. Even a few bits scavenged from somewhere would really help it, ±megabyte of range is in the vicinity of what you need for internal calls but not generally enough.

It's a 32-bit instruction, so why can it only support 21 bits of immediate? Because the people who made RISC-V decided that implicit register arguments are works of the devil, and that you need to use any register as argument for any instruction. Therefore the RISC-V JAL instruction contains a 6-bit field for destination register, which is where they store the next instruction address. Never mind that there is not and will never be a compiler that emits anything but the ABI compliant return address register "ra" to that field, we decided we won't have implicit arguments so by god we are going to pointlessly sacrifice 5 bits⁰ of space in every single fucking branch, often forcing the user to construct the address in a register and use more instructions instead, which is much worse than it sounds, because branch prediction is easier for immediate branches.

This is not the biggest actual problem with the architecture. They added an instruction that adds upper immediate bits to PC, which the any core that implements instruction fusion fuses with jalr. But that sacrifices the low-end, that doesn't fuse anything, and uses two instructions for an extremely common pattern that everyone else manages in one. The reason I hate this one so much because there is no actual reason to make this mistake. A five minute conversation between two engineers should have killed this one in the crib, literally everyone knows not to do this. Apparently other than the RISC-V folks.

0: I give them one bit, because the opcode is short and they use the zero register to suppress the link and turn it into a normal jump.

camel-cdr 1 day ago||
https://github.com/riscv/riscv-isa-manual/pull/3269
Rohansi 17 hours ago||
Everything being an optional extension is covered by the article. It's bad enough for OpenGL and Vulkan but to burn that into silicon and not have a reliable way to detect them is way worse!
adrian_b 18 hours ago||
+++

Excellent and well written description of the RISC-V ISA.

__d 1 day ago||
So … use RISC-V as the strawman, and create a community-based RISC-6 that doesn’t have these weaknesses? Better to get in now before it becomes too solidly entrenched.
inigyou 1 day ago||
You can't make a community-based ISA, it's not possible unless you have a community-based fab. He who makes the chips makes the rules.
__d 14 hours ago|||
Err … RISC-V is an ISA without a fab?
monocasa 1 day ago|||
I mean, a shuttle run is pretty cheap these days. If you have silicon, and customers, scaling past a shuttle run that worked is pretty low additional cost.
inigyou 1 day ago||
It's not really a community though is it?
IshKebab 1 day ago||
Likely impossible unless you somehow come up with something vastly better (unlikely).

None of these things are remotely bad enough to make the downsides of using another ISA palatable.

hajile 10 hours ago|||
How about EPIC-esque packet-based instructions?

64-bit instructions with 4 bits indicating instruction formats (60-bit, two 40+20-bit variants, 30+30-bit, 20+20+20-bit, three 30+15+15-bit variants, and 15+15+15+15-bit). Have each larger instruction type be a strict superset of the smaller instructions, but with larger immediates, more registers, and maybe additional instruction formats (eg, for SIMD).

Something like that would be even easier to decode (converting short instructions to long is simply a bit of wiring). Instruction density should increase due to 20-bit instruction type. Having properly-aligned instructions would help with fetching performance. Larger instructions means you can jump 4x further with the same immediate and 16-bit offsets. No need to have some of the V extension workarounds (from not wanting to add 48-bit instructions).

NetMageSCW 1 day ago||||
Anther ISA like ARM? It seems pretty palatable to just about everyone not academic.
duskwuff 1 day ago|||
The ARM ISAs are not free to implement. ARM holds patents relevant to the ISA.
phendrenad2 1 day ago||
Until the patents expire, which many have already.
monocasa 1 day ago||
The aarch64 stuff still has some time, particularly if you want stuff like virtualization.
IshKebab 1 day ago|||
You're vastly underestimating the amount of work that has gone into RISC-V that would need to be redone. It's not just a spec. There's an absolute mountain of software and hardware supporting it.
__d 13 hours ago||
Sure. But … so was Linux, or Firefox, or GNOME or KDE, etc.

Even RISC-V itself was adopted by volunteers and supported by toolchains, and then kernels, and applications.

The amount of work is less a problem than the motivation. And motivation really just depends on recognizing that the status quo sucks, but is fixable.

__d 14 hours ago|||
And yet, new ISAs arise fairly regularly, for various reasons. RISC-V itself succeeded largely because it is gratis, I think.
brcmthrowaway 1 day ago||
> What does a cheap microcontroller core need? Let's inspect what they are used for. Typical use cases are to interface with and quickly reconfigure hardware blocks in a larger chip, eg in an MP3 player, an SD card, or a USB stick. The hard work is done by custom IP and the CPU core is just there to occasionally prod a register or configure something.

He forgot electronic cigarettes (vapes)

dmitrygr 8 hours ago|
My apologies. I’ll update my shitpost with this example. :)
random__duck 1 day ago|
I wonder if they will be inviting him to the next RISC-V design committee meeting.
dmitrygr 1 day ago|
For a friendly meeting, like Julius Caesar had on March 15, 44 BC.
random__duck 1 day ago||
"This time its different".
More comments...