Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> You're not really supposed to write AVX yourself - the compiler should be doing that for you. And it will, if you write your code in a SIMD-compatible way and turn on the right compiler flags.

Take it from experience: sure you can write high-level code that is SIMD-compatible. But the compiler is garbage at understanding the semantics and will write terrible SIMD code.



The best thing a current compiler can provide is probably replacing intrinsics with more conventional-looking things like GCC's Vector extensions[1] and C++'s simd<T>. Even then you'd need to do a little bit of union work for the cooler operations.

[1] https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html


The union work turns out to be a lot because compiler extensions and simd<> barely support anything beyond operators.

Examples of what's missing: interleaved load/store, compress/expand, software AES/CLMUL, popcount, lzcnt, saturated add/sub, 128-bit compare/minmax, fixed-point mul, mask find/set, masked load/store, scatter/gather, reductions.

Highway supports those (and >200 operations in total) on all platforms.


I 100% agree that there's a lot of room for improvement here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: