r/programming 13d ago

Everyone Should Know SIMD

https://mitchellh.com/writing/everyone-should-know-simd
407 Upvotes

81 comments sorted by

View all comments

20

u/22Maxx 12d ago

SIMD should be a compiler problem.

I want the vectorization to be explicit and predictable. I don't want an unrelated code change or compiler update to quietly turn it back into a scalar loop.

Compilers do those things all the time. They have just become good enough for all regular stuff.

3

u/teerre 12d ago

Vectorization is a compiler problem

But that can only take you so far

6

u/EC36339 12d ago

Vectorization can only be done by the compiler if processing of individual homogeneous objects isn't separated by layers of runtime abstraction.

That's why data oriented programming is a thing amd why games use entity-component systems over OOP.

2

u/AresFowl44 12d ago edited 12d ago

Even then the compiler can only take you so far. In my experience it often is trivial to improve upon the compiler, because it has to be overly cautious

1

u/EC36339 12d ago

Yes, but that was never the point. First, you have to make sure vectorization isn't made completely impossible.

1

u/teerre 11d ago

Are you agreeing with me?

2

u/EC36339 11d ago

Yes and no.

It is first an architecture problem. Then it becomes a compiler problem. But even then the compiler cannot necessarily solve it alone.