Looking at Intrinsics in C

AVX Registers
From WikiMedia. https://commons.wikimedia.org/wiki/File:AVX_registers.svg

This post probably has the most mystifying title yet. Here’s a little background. Modern CPUs have some hardware that can speed up operations like addition or multiplication by doing them in parallel. The words SIMD (short for Single Instruction Multiple Data) and vectorization apply.

These are very processor specific. Even something like x86-64 CPUS have a whole raft of alphabet soup. SSE, MMX, AVX. Intel even have a website so you can see what instructions are supported with examples in C.

My i5930K CPU supports AVX so if you tick the AVX box on the left hand side of the Intel intrinsics guide, you  can see can there are something like 12,000+ instructions and variants listed. If you tick one of the categories, it filters out the instructions to those applicable to that category.

Click one of the instructions on the right and you’ll see a rough equivalent in C to what it does. Also the header that it is found in, typically

#include <immintrin.h>

which  Visual C++ is happy to compile. An intrinsic is a special C instruction that gives you access to these low level vectorization instructions without you having to drop into assembler.

On a Raspberry Pi, the ARM processor supports a similar type of scheme but it’s called NEON.

If you are interested in finding out more, take a look at Microsoft’s intrinsics documentation which covers both Intel and ARM.


Leave a Reply

Your email address will not be published. Required fields are marked *