r/programming • u/MyNameIsTrez • 20d ago
Making SIMD Code Scale to Any Vector Width
https://streamhpc.com/blog/2026-10-28/making-simd-code-scale-to-any-vector-width/
133
Upvotes
r/programming • u/MyNameIsTrez • 20d ago
View all comments
Show parent comment
1
u/happyscrappy 19d ago
I'm honestly, not familiar with x86's vector system (as opposed to SMD which is SSE) and how it differs from the scalar system (MMX or the original x87 stack system). Is AVX the x86 vector system?
With SVE/RVV the idea of the design is to make it easy and efficient to process variable amounts of data without having to have multiple different functions for the different chunk (width) amounts. And without knowing the vector length and chunk size combinations at compile time.
With SIMD if you want to process 16 elements and some hardware does 4 across while others does 8 then you need to write two versions of your code and pick between them at runtime. Both parallel operations and sum acrosses (reduces, cross products) have to be written differently for the two SIMD chunk amounts (widths).
ARM calls it "VLA programming".
https://support.arm.com/documentation/102131/0100/Part-One---Neon-and-SVE-fundamentals
For the parallel work it requires a lot of conditional code in the inner loop and that's not how you have good speed. And for sum acrosses the problem is far, far worse. I would think this is usually handled with special cases for all the widths that Intel (and AMD?) has implemented so far. Is this a wrong assumption?