3 ms·
> On a test with a Linksys NSLU2 (ARMv5TE processor) the speedup was a factor 5 (big endian mode, gcc 4.1.2, -O3) Now that's a name I hadn't heard in a long lo
by mschuster91 3y ago
> On a test with a Linksys NSLU2 (ARMv5TE processor) the speedup was a factor 5 (big endian mode, gcc 4.1.2, -O3)
Now that's a name I hadn't heard in a long long time.
The post is from 2008 anyway, I wonder what would happen if one were to put this code (or the earlier, non-unrolled-loop versions) to the test with modern compilers that can do all sorts of black magic for performance, or if it could be extended to take advantage of modern CPU features.
- mastax 3y agohttps://godbolt.org/z/szMvnTT63 https://godbolt.org/z/szMvnTT63 Looking at the naive code from Analysis 1 and comparing GCC 4.1.2 to GCC 13.2 there's a huge difference. Even when forcing both to generate code for the same old architecture (k8) so its more fair. GCC 4.1 generates code which is a pretty direct translation of the source: branchy, operates on bytes. GCC 13.2 does a ton of optimization. There's only a single jump/loop. It uses prefetch. It uses SSE instructions to operate on 128-bits at a time. It looks like all the instructions are duplicated as well to operate on a pair of registers, too. I'm not exactly sure.
- ack_complete 3y agoGCC is just vectorizing the code literally. It's doing multiple bytes in each loop iteration, but the vectorized code is still bit-testing the index to conditionally XOR into each accumulator. This is still much less efficient than taking advantage of the regular patterns as in the latter parts of the article. It also runs with a lot less lanes than it could, because it uses 32-bit lanes instead of 8-bit for some reason.