News for hackers. Stuff that matters.
Re:A Big Week for RISC-V by MaKey on Sunday February 13, 2022 @06:35AM (#30321027)
If everyone implements their own custom extensions, you would have to compile your software for each RISC-V device. To be able to do that, the compiler needs to support those extensions. I think that is what was meant with "you lost software compatibility".

Edit: I am mistaken, thanks everyone for educating me.

Re:A Big Week for RISC-V by vbezhenar on Sunday February 13, 2022 @06:42AM (#30321061)
Intel CPUs have plenty of optional extensions. Basically you're building two versions of machine code and choose correct one at runtime.
Re:A Big Week for RISC-V by MaKey on Sunday February 13, 2022 @06:58AM (#30321142)
How would that work if you have a hundred custom extensions?
Re:A Big Week for RISC-V by rwmj on Sunday February 13, 2022 @07:01AM (#30321151)
Apparently it works fine:

  flags  : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d
Re:A Big Week for RISC-V by colejohnson66 on Sunday February 13, 2022 @08:21AM (#30321585)
Forgive my ignorance if there’s an answer, but for x86, those extensions don’t overlap (mainly because Intel and AMD avoid stepping on each other). RISC-V doesn’t have a guarantee of non-overlapping vendor extensions, no?
Re:A Big Week for RISC-V by dzaima on Sunday February 13, 2022 @08:33AM (#30321651)
There's no way to prevent overlapping extensions. One could easily make an x86 extension that overlaps with some existing one. There's just as much an incentive to not do that for x86 as there is for RISC-V.

See AMD's SSE5 vs Intel's SSE4 conflict in x86 - both have instructions that the other doesn't have, and some that both have, and, from what I understand, even the instruction formats conflict.

Re:A Big Week for RISC-V by saagarjha on Sunday February 13, 2022 @08:45AM (#30321729)
> One could easily make an x86 extension

One cannot easily make an x86 extension because there are approximately ~3 entities on the planet allowed to make x86 extensions.

Re:A Big Week for RISC-V by sudosysgen on Sunday February 13, 2022 @11:26AM (#30322849)
Not really, China also added their own crypto extensions to x86 chips, though under AMD/VIA's license.

I wouldn't be surprised if Sony/Microsoft did too for their consoles.

It's doable if you have enough money to get AMD or VIA to make you a one-off.

Re:A Big Week for RISC-V by dzaima on Sunday February 13, 2022 @08:52AM (#30321759)
Here's my random x86 extension: the byte sequence 0xc5,0xfd,0xd4,0x00 sorts the 64-bit floats in ymm0. It conflicts with AVX2. :)
Re:A Big Week for RISC-V by saagarjha on Sunday February 13, 2022 @09:03AM (#30321815)
You’ll have trouble shipping that extension. Not because it conflicts with AVX2, but because Intel will sue you for your comparability with the rest of x86.
Re:A Big Week for RISC-V by MaKey on Sunday February 13, 2022 @07:13AM (#30321199)
I wasn't aware that we already have so many extensions. But doesn't the binary get more bloated the more extensions you have?
Re:A Big Week for RISC-V by dzaima on Sunday February 13, 2022 @07:21AM (#30321226)
In practice, at least C compilers don't automatically generate code for multiple extensions, so you get the performance of the base ISA by default. This does indeed mean that every C program for x86-64 that isn't compiled with a specific target architecture just won't ever use AVX/AVX2/AVX-512/any other extension.

There is the idea of profiles, i.e. a single nice name for a group of extensions so that there's something one could provide a precompiled binary for, but I don't know what, if any, are RISC-V's plans for that.

Re:A Big Week for RISC-V by snvzz on Sunday February 13, 2022 @05:22PM (#30326221)
>but I don't know what, if any, are RISC-V's plans for that.

Profiles. See RVA22.

Re:A Big Week for RISC-V by rwmj on Sunday February 13, 2022 @12:26PM (#30323478)
With x86 there are common extensions that form a baseline (eg. you need SSE2 for any program to run at all). And there are more specialized extensions, eg. for high performance mathematical work. The specialized extensions can usually be confined to a library, and the library can work out at runtime what the hardware supports and swap in optimized functions.

It'll likely work much the same way for RISC-V, eg. in Fedora we require that the C (compressed) extension is supported, otherwise the distro won't boot, and things like the vector extension will probably be used only by specialized math libraries and the like.

Re:A Big Week for RISC-V by demindiro on Sunday February 13, 2022 @07:22AM (#30321238)
You can choose which extensions to support at compile time and whether this extension is optional. E.g. many binaries don't use AVX at all, while binaries compiled with -march=native may assume that AVX is supported (and emit SIGILL if not).
Re:A Big Week for RISC-V by panick21_ on Monday February 14, 2022 @06:50AM (#30330913)
Open Source software will not adopt 100s of costume extensions. If something becomes a standard it will likely move into a reserved place.
Re:A Big Week for RISC-V by makapuf on Sunday February 13, 2022 @06:44AM (#30321067)
Isn't it the same with some ARM vendors ? Of course, a random foundry can't, but what's preventing Apple from including specific instructions on their core (not that it would make sense) or a specific coprocessor that may or may not be integrated ?
Re:A Big Week for RISC-V by saagarjha on Sunday February 13, 2022 @08:51AM (#30321754)
Apple does ship custom instructions on their code but does not expose it to third parties: their external compilers will not generate those instructions, and they remain in the kernel and system libraries where they can be hidden behind APIs without being directly exposed.
Re:A Big Week for RISC-V by geokon on Sunday February 13, 2022 @06:42AM (#30321056)
I find it hard to believe there is no way to probe for extensions and provide a fallback

It's a problem that already exists right now.

If you compile code on a machine with SSE or AVX and run it on an old Pentium, does it crash?

I had a fun bug once running ARM code that had some NEON in it and it would crashed on Scaleway's VPS bc their servers ran chips that didn't have NEON implemented

Re:A Big Week for RISC-V by rwmj on Sunday February 13, 2022 @06:59AM (#30321145)
This is the standard FUD spread around by Arm apologists. Of course you can detect RISC-V extensions at both compile and run time. In fact it's the first widespread ISA that was designed with extension in mind (so for example there's a uniform way to find instruction boundaries even if you do not know how to fully interpret an extension). This is in stark contrast to x86 where extensions are basically hacks piled on hacks.
Re:A Big Week for RISC-V by saagarjha on Sunday February 13, 2022 @08:50AM (#30321753)
> so for example there's a uniform way to find instruction boundaries even if you do not know how to fully interpret an extension

This doesn’t make sense, though. If you have something in your instruction stream that you don’t understand, it would be insane to do anything but fault immediately, unless the instruction is some sort of optional feature such as a hint or security mechanism where there is no real behavior associated with it. I mean ARM has this “capability” too by virtue of a fixed length instruction set but it doesn’t do anything with this like you’re describing.

Re:A Big Week for RISC-V by tux3 on Sunday February 13, 2022 @11:30AM (#30322893)
It will be useful for disassemblers, among other things.
Re:A Big Week for RISC-V by saagarjha on Sunday February 13, 2022 @06:41PM (#30326775)
Sure, it’s helpful but not really a requirement by any means. Normal x86 code tends to be self-synchronizing, for example.
Re:A Big Week for RISC-V by MaKey on Sunday February 13, 2022 @07:25AM (#30321250)
Sorry, my post was not intended to be FUD. I tried to follow the original claim but apparently placed too much merit in it.
Re:A Big Week for RISC-V by ori_b on Sunday February 13, 2022 @08:54AM (#30321771)
> If you compile code on a machine with SSE or AVX and run it on an old Pentium, does it crash?

Yes. Or it leaves them unused on the machine with avx.

For short runs of instructions, the overhead of fallback selection is larger than the overhead of using the least common denominator. For large functions, fallback selection is done by selecting specific functions after benchmarking.

Re:A Big Week for RISC-V by rjsw on Sunday February 13, 2022 @10:04AM (#30322119)
Plenty of open source packages probe for extensions when built for either X86_64 or ARM, then call fallback code if the extension isn't there.

Things like OpenJDK, pixman, nss, ffmpeg.

Re:A Big Week for RISC-V by fake-name on Sunday February 13, 2022 @06:45AM (#30321082)
Something something gentoo is eating the world.