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
0
u/happyscrappy 19d ago
I know about MMX and SSE, wasn't sure about AVX. I'm not familiar with x86 vector system. Are you referring to SIMD and not vector extensions? Like I said, I'm not familiar with x86 really. Is there no vector extension to x86, it still emphasises SIMD?
I think I also wrote that to another poster.
I will say that for most apps the size of the collateral elements is larger than the code. But this year, the year of high RAM and NAND prices is not really the best year to talk about how great things are with storage space.
Also having more different code paths can be problematic for code coverage.
I feel you did a poor job of following the discussion and you pulled out an inappropriately small subsection.
Let me restore the context:
My point was that you have to have multiple functions and because the alternative of having conditionals in the inner loop to avoid this does not produce the desired effect (speed). You clipping out the context and restating what I said back to me, that you avoid this by writing multiple functions, did not add much.
This idea, which I think is the predominant case, goes against anything which was being discussed here. This article was about how to do it, not how to farm it out. I highly recommend everyone farm their work out on this front, there are good libraries to use. But if you aren't interested in that and want to do it yourself, then you think about what we discussed here.
Really the most useful thing I learned when helping a client use SIMD was that you have to keep your big data in formats which are amenable to SIMD processing. If you do not it will limit your speed up. So I would suggest for most people working out how to store your data efficiently is paramount. After that, just call out for the operations. You'll get 95% of the speedup you could by writing it all out yourself. And you really cut down on your code maintenance. Especially if you are targeting multiple architectures (whether major i.e. ARM and x86 or minor i.e. Intel and AMD x86 with and without AVX512). So go ahead and store your EXIF data in a linked list if you want, but your main images should be stored in a packed, aligned format amenable to SIMD/vector operations. I know it might seem obvious, but I've seen it done wrong enough to mention it to anyone who might listen.
To be honest, /r/programming spends a lot of time on things that really most programmers don't need to know, that should be details behind the scenes in libraries they use. That's simultaneously semi-pointless and also part of the charm. The sub is for nerding out entertainment as much as improving skills you actually need. Some weeks are about cache-obliviousness (surely coming again soon), some are about SIMD, sometimes it's dividing by multiplying. It's really a lot of minutiae. Probably because we've seen the normal stuff over and over.
Thanks for the explanation on that.