r/cpp • • May 27 '26

Accelerating copy_if using SIMD

https://loonatick-src.github.io/posts/vectorized-copy-if-analysis/
46 Upvotes

15 comments sorted by

View all comments

Show parent comment

1

u/mark_99 May 27 '26

True, although I was referring to the Zen 4 hardware implementation as it's kind of bolted on to the underlying 256-bit units.

Agreed AVX-512 is absolutely a better instruction set so it's worth it in that sense, but the general rule of thumb is that (a) Zen 4 AVX2 vs AVX-512 performance is generally near 1:1 and (b) Zen 5 is 1.8-2x Zen 4 for AVX-512 as it's a native implementation.

I did a lot of profiling on a 7950X vs 9950X3D2 and this held up across auto-vectorized, hand-rolled intrinsics and optimised libraries such as OpenBLAS (the extra cache on the 9950X3D2 probably helped in real-word perf also).

For vpcompressd specifically if you don't care about overstore it's 1.33 cycles vs 1.0 and then a regular store so maybe quite close. If you want masked store then you're back to around 2x for the extra instructions described in the blog post.

3

u/fsfod May 27 '26

I thought Zen5 is still stuck with the same bandwidth through its L2\L3 cache and IO die as Zen4.

2

u/looncraz May 28 '26

Zen 5 has joinable load pipes - it has 512-bit L1D and L2 cache load capabilities.

Above the L2, IIRC it remained the same, but that data was always loaded async and predictively, so not really usually much of an issue.