5 ms·
He didn’t gain 10x from a micro optimization, he gained that much by converting it to use SIMD which is a macro optimization. You usually have to structure your
by david2ndaccount 4y ago
He didn’t gain 10x from a micro optimization, he gained that much by converting it to use SIMD which is a macro optimization. You usually have to structure your program in such a way to be SIMD friendly. In this case it was already simd-friendly (adding a large number of floats).
- Jensson 4y ago> In this case it was already simd-friendly (adding a large number of floats). So it was micro optimization afterall!
- lmm 4y agoIt was a micro optimization because it was a toy example. Doing floating-point arithmetic (and not already using BLAS etc.) is very niche in real code.
- Jensson 4y agoIt is still micro optimization to ensure that those instructions are used when the compiler is too dumb to use them. You can say that they are niche, but that is different from it being micro optimization.
- lmm 4y agoIt's not the compiler being dumb, it won't use those extensions because they reassociate the arithmetic and change the result - and setting that compiler flag is very much a macro rather than micro change.
- Jensson 4y agoBut he didn't set the compiler option, he rewrote it to explicitly use those instructions, that is micro optimization no matter how you look at it. The reason micro optimization is so easy to get better than compiler results is that you know things about the data the compiler doesn't, like in this case you know it is fine to reorder the result while the compiler is too dumb to know that. You need much smarter compilers than we have today in order for such micro optimizations to stop paying dividends.
- lmm 4y agoMaking sure it will behave correctly with that change (which changes the result of the function!) is a macro change - you have to trace the implications all the way through the program.