| ▲ | cmovq 4 hours ago | ||||||||||||||||||||||||||||||||||||||||||||||
Compilers can’t really, in a meaningful way, change the layout of your data in memory. And you do need to think about your memory layout to get any benefit from SIMD. You’ll notice a lot of compiler auto vectorization insert many instructions just to shuffle data around to get to a usable layout, which negates much of the benefit. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | motoboi 30 minutes ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
This is actually a very nice question and the answer is that interpreted languages with a JIT benefit from this. One example is Java, which will happily vectorize your code into AVX or SSE where possible. Python just got a JIT compiler and we’ll start seeing the same thing soon. But as someone else said here, some constructs don’t translate well and adding transformations to show vectorization would negate the perfomance gains. Sad that the compiler (even Java) can’t explain you this and warn about it, but now with LLM, maybe they’ll start doing things like that soon. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | fulafel 3 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Depends on the programming language. A good question is why we don't have more optimizable languages in mainstream use. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||