blog · git · desktop · images · contact


x86-64 and beyond

2022-01-29

My current CPU, an Intel i7-3770, supports “x86-64”. When I want to install software, I have to check that. This is usually only relevant for the operating system itself, though (at least in the world of Linux).

Problem is, “x86-64” is about 20 years old now. Since then, there have been a number of additions. As usual, this is very chaotic: Some CPUs support some features, others support other features. So, when you buy a CPU capabale of “x86-64” today, it’s very much not the same thing as an “x86-64” CPU from 2005 or even 2015. This means that software compiled for a modern CPU might not run on an old one, even though both use the same “architecture”.

To be more precise, all those CPUs have the same base set of instructions – and newer CPUs support additional instructions. If you issue one of those additional instructions on an old CPU, you’ll get a SIGILL. And the problem is that nobody has ever really defined: “When you support the base set, plus this, and that, and that thing over there, then you can call it a ‘x86-64-foobar’ CPU.”

Something similar happened in the 32 bit PC world: i386, i486, i586, i686, … I think I remember that there was a clear distinction between i386 and i486 (maybe I’m wrong, it was a long time ago), but after that, it got confusing here, too. “i586” was not popular enough as a marketing term, so they called it … “Pentium”. The “i686” that followed was vague, too, and – like “i586” – not an official Intel name.

Back to “x86-64”.

Arch Linux once “marketed” itself as an “optimized” distro. At the time, this meant i686. Eventually, the i686 version was dropped in 2017 – and then it kind of wasn’t “optimized” anymore. It was just x86-64, because that was modern enough anyway. But as mentioned above, there have been lots of improvements since the original x86-64. So some Arch devs wonder if they shouldn’t go back to being “optimized”. (This is not about marketing, but about making good use of the features of your CPU. Arch is a community project, nobody benefits from millions of users.)

But optimized for what? There are no names, no “i786” or “i886” or something like that. Well, that appears to have changed:

https://gitlab.archlinux.org/archlinux/rfcs/-/blob/master/rfcs/0002-march.rst

This is an Arch-internal RFC and it mentions that there are “x86-64-v2” through “x86-64-v4” now. I’ll copy the text here, in case the URL above ceases to function:

The first of these microarchitecture levels, x86-64-v2, assumes the following on top of base level x86_64 instructions:

CMPXCHG16B, LAHF-SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3.

This basically raises the processor feature level requirement to around Intel Nehalem, and supports any x86_64 processor made in the last decade.

The x86-64-v3 microarchitecture requires the following instruction sets:

AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE.

That is close to a Haswell processor, but does exclude some recent low end Intel CPU that removed AVX support.

Finally, x86-64-v4 requires:

AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL

It’s interesting to note that these names have not been made up by Arch but by “AMD, Intel, Red Hat, and SUSE”. We can (hopefully) expect these names to become the new “standard”, a bit like i386 and i486 once were. Wikipedia lists an e-mail from Florian Weimer on the LLVM mailing list as the source (or rather, the origin of the discussion).

glibc provides a way to check this microarchitecture level, so you don’t have to search through all the CPU flags in /proc/cpuinfo:

$ /lib/ld-linux-x86-64.so.2 --help

Subdirectories of glibc-hwcaps directories, in priority order:
  x86-64-v4
  x86-64-v3
  x86-64-v2 (supported, searched)

So, in my case, I’m on x86-64-v2. Welp, my machine is 9 years old now. My NUC from 2017 with its Celeron N3050 is only x86-64-v2, too. My netbook from 2011 with its Intel Atom N455 is not even x86-64-v2, just x86-64. Then again, my notebook from 2014 with its i7-4710MQ is already x86-64-v3. But not even my notebook at work from 2019 (i7-8665U) is at x86-64-v4.

For now, Arch just thinks about supporting x86-64-v3 as an additional architecture. I suspect that the x86-64-v3 port will coexist with the “old” x86-64 port for quite a while, so I wouldn’t worry about removal, yet. There had been strong objections in the thread on the mailing list to completely removing x86-64, when this idea first came up in March 2020. Of course, it will happen at some point, i386 is dying out across distros, too, but we’re not there, yet.

… at the other end of the spectrum …

Via The Gopher Times – Opus 3:

The computer built to last 50 years by Ploum. A very appealing vision.

Comments?