2 ms·
Here is an example of a program that would not have been written without Intel's GCC intrinsics: https://NN-512.com https://NN-512.com Intrinsics are better t
by 37ef_ced3 5y ago
Here is an example of a program that would not have been written without Intel's GCC intrinsics:
https://NN-512.com https://NN-512.com
Intrinsics are better than direct assembly because GCC can simplify, combine, and reorder instructions (e.g., lift them out of loops). GCC handles register allocation, etc. Intrinsics dramatically simplify the programmer's job
The GCC codegen is fantastic for NN-512, overall
GCC 8.3 and earlier make a few mistakes, like compiling FNMADD as xor-negation followed by FMADD (using an extra register for the xor-negation constant), but those problems have been fixed in GCC 9.1 and above
The only codegen mistake I see in GCC 10 is when I load 512 bits from memory, convert the low 256 bits from packed-half to packed-single, and do the same thing for the high 256 bits. GCC sometimes reloads the 512 bits from memory (despite still having those bits in a register). It doesn't harm performance much, but it seems dumb. Not sure why GCC does this
GCC can reduce the liveness range of an in-register value by moving the producing instruction and consuming instruction closer together. This can be a big help if you're writing code that just barely fits in the register file. For example, NN-512 produces many loops that use almost all of the 32 ZMM vector registers. GCC generally does a good job avoiding spills, if the programmer doesn't make the job too hard
In my opinion, properly written C intrinsics produce very good AVX-512 machine code, much more easily than if I wrote the assembly by hand. You can write much larger, more complex, fully vectorized programs when GCC helps you