Search code examples
x86header-filesssesimdintrinsics

Header files for x86 SIMD intrinsics


Which header files provide the intrinsics for the different x86 SIMD instruction set extensions (MMX, SSE, AVX, ...)? It seems impossible to find such a list online. Correct me if I'm wrong.


Solution

  • These days you should normally just include <immintrin.h>. It includes everything.

    GCC and clang will stop you from using intrinsics for instructions you haven't enabled at compile time (e.g. with -march=native or -mavx2 -mbmi2 -mpopcnt -mfma -mcx16 -mtune=znver1 or whatever.)

    MSVC and ICC will let you use intrinsics without enabling anything at compile time, but you still should enable AVX before using AVX intrinsics.


    Historically (before immintrin.h pulled in everything) you had to manually include a header for the highest level of intrinsics you wanted.

    This may still be useful with MSVC and ICC to stop yourself from using instruction-sets you don't want to require.

    <mmintrin.h>  MMX
    <xmmintrin.h> SSE
    <emmintrin.h> SSE2
    <pmmintrin.h> SSE3
    <tmmintrin.h> SSSE3
    <smmintrin.h> SSE4.1
    <nmmintrin.h> SSE4.2
    <ammintrin.h> SSE4A
    <wmmintrin.h> AES
    <immintrin.h> AVX, AVX2, FMA
    

    Including one of these pulls in all previous ones (except AMD-only SSE4A: immintrin.h doesn't pull that in)

    Some compilers also have <zmmintrin.h> for AVX512.