4 ms·
The clang code loads the 8-bit words into 16-bit vector instructions and parallelizes using a tree-algorithm to minimize dependencies. So already it's better t
by CoolGuySteve 8y ago
The clang code loads the 8-bit words into 16-bit vector instructions and parallelizes using a tree-algorithm to minimize dependencies.
So already it's better than "pretty good" and it's still verbose.
But neither of these compilers are able to optimize for code size while using AVX, so the ((code size)/64byte cacheline) * (~100ns loads) will still kill your performance on any data set that's smaller than a few kilobytes.
- dragontamer 8y ago> The clang code loads the 8-bit words into 16-bit vector instructions and parallelizes using a tree-algorithm to minimize dependencies. You specified the "int sum", so that means "sum" needs to follow 32-bit overflow semantics. I don't think it is possible to do 8-bit > But neither of these compilers are able to optimize for code size while using AVX You can totally do that. You're specifying -O3, which is "speed over size". If you want size, you want -Os, and then use -ftree-vectorize to enable the auto-vectorization.