I’ve been experimenting with various techniques for vector/SIMD programming in C/C++ and Python (for code generation) using Intel/AMD AVX-512 processors and ARM Neon processors. The performance of various CPUs turned out to be interesting.
I used an EC2 c8i instance for one set of AVX.
For NEON, I used an EC2 t4g instance, an AppleM4, and a Raspberry Pi 5 as well.
What size t4g were you running? Smaller sizes have a limit for how much CPU you can burn on them. A better apples to apples comparison would be to use a c class instance
Nice benchmark — two things in the numbers are worth pulling apart.
First, the Xeon curve falling off past ~6000 samples is the giveaway that the large-N end isn’t measuring vector throughput anymore, it’s measuring memory bandwidth. Once the working set stops fitting in cache, a 512-bit register doesn’t help because the cores are waiting on DRAM. If you rerun with the data pinned in cache (or report GB/s alongside the speedup), the AVX-512 lead at large N should mostly flatten out to the bandwidth ratio.
Second, on the Graviton side, the t4g result is hurt by two things: it’s a burstable instance, so sustained runs can get throttled once credits run out, and std::experimental::native_simd on Arm only emits fixed 128-bit NEON — it can’t use the SVE2 vector length that Neoverse V3 (Graviton5) actually has. So the Graviton5 jump you’re seeing is mostly better cores and memory, not the wider vector path. A c7g or c8g vs the c8i would be the apples-to-apples comparison, and compiling with SVE2 enabled would be the interesting follow-up — that’s where the Arm numbers usually close the gap a lot more than the NEON baseline suggests.
I’m aware of the caching issue, but I keep those in the datasets so as to illustrate exactly that.
To your point of using the SVE2 instructions, I’m exploring that with some initially frustrating results. I’ve been manipulating the compiler settings with “-march=armv9.2-a+sve2 -msve-vector-bits=XXX”
Setting sve-vector-bits to 128, everything works as expected.
However, setting it to 512 the
std::experimental::native_simd::size()
reports the correct size of 8, I’m getting segfaults and comparison failures with the C++ code, even with simplest of loops. I’m going to go back and implement the C intrinsics with SVE2 and see if that works and raises the bar
I’ve been taking a look at the SVE/SVE2 intrinsics and their implementations. Yes, the spec goes up to 2048 bits, but unfortunately no is selling a chip like that at the moment. Graviton 2 has 128-bit registers, and Graviton 3 has 256-bit registers, but Graviton 5 goes back down to 128.
Though there does seem to be some strangneses. Compiling with -march=armv8.5-a+sve for a Graviton 3(c7g)
implementation
-msve-vector-bits=128
-msve-vector-bits=256
simd::size()
2
4
std::reduce
8x
4x
NEON intrinsics
14x
7x
vector_reduce_simd
10x
10x
Yes, when we boost the size of the vector, the performance of the NEON intrinsics goes down