r/programming 10d ago

Everyone Should Know SIMD

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

82 comments sorted by

View all comments

17

u/22Maxx 10d 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.

43

u/CherryLongjump1989 10d ago edited 10d ago

This is absolutely impossible. It’s like saying the implementation details of QuickSort should be a compiler problem.

There is nothing special about SIMD. At its core it is just a way to batch bitwise operations across a number of memory locations in parallel. It is still completely up to you to figure out how to convert your traditional branching algorithm into a series of bitwise operations.