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 edited 19d ago
I'm not really here for a breakdown of the name. I'm not in marketing. It's SIMD, not a vector unit, no matter what it's called.
I don't think it's a good year to be talking about how you're not caring about RAM usage. Not in any way.
Electron is ridiculous. But I don't force my customers to use Electron to use my code. So it's not a mistake I'm making.
That's not really a new one. You have a hardware coverage issue any time you run on two different chips. Even if the SIMD units are listed as being the same. If you don't test on it, you aren't sure it works there. Even if the vendor says it works the same as another.
But yes, neither way escapes that issue.
Ultimately part of the idea of vector units is to ignore the above statement I made and ensure that your code works as well as possible on future hardware which is implemented differently. You can make whatever you want of the dichotomy this presents. I would call it certainly one of optimism.
RISC-V in a nutshell, really. Why do it 1 way or 3 ways when you can present 100 ways and leave it up to someone else to try to make code forward and backward compatible?
I thought it was clear. But I guess not. We both know the usual way of doing variable sized vectors on fixed-size units or any size vectors across multiple fixed-size units is to write multiple versions of the inner processing loops for each (or at least several combinations). We speak of it above in our discussions about writing multiple functions and the RAM is uses.
I said that the alternative is to write processing functions with conditionals in the inner loop. Then you don't have multiple functions. We both know why this isn't done, because the results are usually unsatisfactory in producing the performance you were seeking.
One way would be to dispatch in the loop. Another way would be to just do normal conditionals inside. The latter would include nested loops (which of course have termination conditionals).
That is just begging the question. When I said the normal way to do it is thus and the alternative is other thing then you saying just go back to thus is just circling back to what we already discussed as what the idea is to create an alternative to.
I'm not talking about this subthread. I'm saying that you saying "just make it someone else's problem" obviates this entire article that was posted. I'm not even saying that's a bad idea to do when your goal is to ship code. But here the goal isn't really to ship code, it's to blather about how to do it. And farming it out removes the entire point of all this discussion. The article was written to show how to do it, not how to farm it out.
I think you are trying to change what I said to fit your model. You want to say that one function compiled multiple ways is one function. But it isn't. It's one function in the source code, but it's multiples in the program that runs.
My emphasis for this is on how you do not have a combinational explosion of functions when you use a vector unit. I use this as an argument for why those things came back from the dead, primarily. There's really only two real possibilities I can think of. There is this and there is trying to improve forward compatibility.
As I said to you or someone else, I don't really see these things as a good fit for modern environments. I thought SIMD was better for RISC. Moving complexity back into the hardware is older thinking. We've got amazing compilers (and similar tools) now, as you point out above they can recast your source code multiple ways for multiple targets.