209 points•verdagon•about 2 months ago•65 comments•

65 comments

ack_completeabout 2 months ago
AArch64 definitely has a much more comprehensive baseline than x86-64, but there are some optional extensions that are situationally impactful, including the Crypto extension and some of the newer accumulation / dot product instructions. And unlike Intel, ARM has no portable equivalent to CPUID for querying feature flags and is terrible at documenting which intrinsics require specific FEAT_* flags.

The ARM-based CPU manufacturers make this worse by posting almost no low-level documentation for their CPUs. For basically any mainstream x86 CPU, it's trivial to find documentation listing what ISA level it supports and general execution widths and latencies for common operations. For the majority of ARM CPUs, there's absolutely nothing. ARM only has optimization guides for selected Cortex cores, and NVIDIA published info for their Olympus core. But execution details had to be reverse engineered for Apple M1, and there is nothing for Oryon. This is especially bad for in-order cores, which unfortunately is still relevant because new CPUs are still being shipped with in-order efficiency cores.

eqvinoxabout 2 months ago
> some optional extensions that are situationally impactful, including the Crypto extension and some of the newer accumulation / dot product instructions.

Or LSE, adding a whole different set of atomic ops... which are way faster on some CPUs...

broheeabout 2 months ago
"The ARM-based CPU manufacturers make this worse by posting almost no low-level documentation for their CPUs."

Are those not based on standard ARM cores or ARM documentation on its cores not deep enough for your purpose?

ack_completeabout 2 months ago
Both. The specific documentation I'm referring to is their optimization guides, such as the Cortex-A72 optimization guide:

https://support.arm.com/documentation/uan0016/a/

This has detailed information on latencies and throughput, which are important when optimizing SIMD code. But ARM doesn't publish optimization guides for all their cores.

On top of that, the cores are often modified in significant ways. Snapdragon CPUs, for instance, have used modified Cortex cores in the past and can have performance differences from the original core.

To be fair, Intel's been slacking a lot on this too, not even bothering to update their own optimization guide for their latest cores. But that's made up for the community mining this information in great detail on sites like uops.info, and also being a lot less x86 cores to deal with. On the ARM side, there's practically not much analogous other than the Apple M1 microarchitecture analysis.

officialchickenabout 2 months ago
I really hope this is my last x86-64 CPU, Intel has become an incompetent steward. The "killer feature" for AVX-2(56) at the time of original release was basically lag/jitter-free video playback. IMO, 512 should have never been released for desktop CPUs and restricted to servers. One day I will to switch to a mainstream Neoverse dev box running linux. I also target Cortex-M in rust, so it's got a lot of the typical issues related to missing docs (e.g. bringup of non-heterogenous cores, meaning that M3/M4 still can't be used in a big.little chip)
Tuna-Fishabout 2 months ago
Why? AVX-512 is the best SIMD ISA anywhere right now. And the width is its least important feature.
nixon_why69about 2 months ago
> IMO, 512 should have never been released for desktop CPUs and restricted to servers.

Why not? To save die space?

tancopabout 2 months ago
> ... you can just assert that they’re all recent enough to at least have AVX2 that was introduced over 10 years ago, and have the program crash or misbehave if it ever runs on anything without AVX2

> However, if you are distributing the binaries for other people to run, that’s not really an option.

This all depends on what kind of software you're making. A lot of games set their requirements about 5 generations back, like FC 27 where the minimum is a Ryzen 1600. That lets them use AVX2 unconditionally and prevent complaints from users who tried to run it with a super old CPU.

Then you get whole Linux distros like CachyOS and Clear (RIP) that rebuild the world for each architecture level and have them as separate variants. I think it still counts as binaries for other people.

swiftcoderabout 2 months ago
The other good(?) news on this front is that Windows 11 only supports chips with at least AVX2, so if you are willing to cut off everyone on win10 and earlier, you can stick to that
ack_completeabout 2 months ago
Pretty sure it only actually currently needs SSE4, since they started compiling it with POPCNT for x86. The official system requirement is Intel 8th gen CPU, but Intel made Kaby Lake and Coffee Lake CPUs that lack AVX.
sharktheoneabout 2 months ago
I am hoping for portable SIMD so much. But I still think that often a manually rolled SIMD will be faster.

Also the state of SIMD in Cranelift is also very WIP. They pretty much just support a subset of 128bit vectors with some rare exceptions.

dwatttttabout 2 months ago
I guarantee you with my lack of skill, my attempt at using portable simd will exist while using manual intrinsics I doubt I'd get there.

The question for me is whether portable simd will result in faster code than plain auto-vectorisation; for the simplest loops auto has me beat (the few times I've tried it), but I imagine as the complexity grows I'll be more likely to try do something that breaks auto-vectorisation, and it'll be more obvious to me when I do that in portable simd.

nextaccounticabout 2 months ago
nowadays it doesn't matter if you personally don't have this particular expertise, people still expect you to use an agent to write this code
astrangeabout 2 months ago
Portable SIMD is a bad abstraction. The only two good choices are "something like ISPC" (basically "autoscalarization", similar to GPU kernels) and "writing in assembly" (ffmpeg does this for a reason).
Archit3chabout 2 months ago
Note that ISPC does not handle symbolic math e.g. sparsity preserving linear solvers or equation simplification a la Mathematica. Manual ASM does. ;)
imtringuedabout 2 months ago
"Hardware that does arithmetic is cheap, so any CPU made this century has plenty of it. But you still only have one instruction decoding block and it is hard to get it to go fast, so the arithmetic hardware is vastly underutilized.

Warning, Nitpick. Saying "hardware [...] is cheap" and "instruction decoding is expensive" (implied) is a minor contradiction. You can actually duplicate instruction decoding just fine, it's the thing before it where things go to hell: Instruction fetching.

Nothing prevents you from building a computer that can fetch, decode and execute 16 instructions at once, assuming they don't all write to the same register.

But if you want to do the same add repeated 16 times you'll need 16 times more program memory and 16 wider read ports on your caches and so on. SRAM is really expensive so this strategy will waste a lot of area on memory that you probably didn't need in the first place. I say this as someone who had to design a chip in university and basically you couldn't even find the primitive CPU in-between the massive SRAM blocks. By reusing the same instruction you can now increase your compute to memory ratio in terms of area.

Just a heads up for people who want to know why SIMD is a thing. I'm not criticizing the article, I just want more people to realize the pain that SRAM represents to chip designers.

cboltonabout 2 months ago
The handwavy section on RISC-V is underwhelming. Yes the ecosystem is still nascent but something like the SpacemiT K3 is far from "abysmal" for vector operations and would make a nice test case with its two core types both supporting RVV 1.0 (one with vlen 256, the other with vlen 1024). On the more industrial side, for example the SiFive Intelligence X280 has been used in TPU by Google for years already and I doubt they are the only ones so calling the ISA completely irrelevant is a bit of a stretch.

Just for the sake of curiosity it would be nice to have a peek at what SIMD in Rust looks like on RISC-V today. Yes, even if it requires some "obscure compiler flags" for now (while we wait for the Oilsm extension).

camel-cdrabout 2 months ago
Also, rust could just be based and make -mno-strict-align the default.

Read the full thread on Hacker News →

Related stories