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.
The Intel® Intrinsics Guide contains reference information for Intel intrinsics, which provide access to Intel instructions such as Intel® Streaming SIMD Extensions (Intel® SSE), Intel® Advanced Vector Extensions (Intel® AVX), and Intel® Advanced Vector Extensions 2 (Intel® AVX2).
The immintrin. h header file defines a set of data types that represent different types of vectors. These are; __m256 : This is a vector of eight floating point numbers (8x32 = 256 bits)
Intel® Advanced Vector Extensions Data Types The __m256 data type can hold eight 32-bit floating-point values. The __m256d data type can hold four 64-bit double precision floating-point values. The __m256i data type can hold thirty-two 8-bit, sixteen 16-bit, eight 32-bit, or four 64-bit integer values.
__m128 Data Types The __m128 data type is used to represent the contents of a Intel® SSE register used by Intel® SSE intrinsics. The __m128 data type can hold four 32-bit floating-point values. The __m128d data type can hold two 64-bit floating-point values.
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.
On GCC/clang, if you use just
#include <x86intrin.h>
it will include all SSE/AVX headers which are enabled according to compiler switches like -march=haswell
or just -march=native
. Additionally some x86 specific instructions like bswap
or ror
become available as intrinsics.
The MSVC equivalent of this header <intrin.h>
If you just want portable SIMD, use #include <immintrin.h>
MSVC, ICC, and gcc/clang (and other compilers like Sun I think) all support this header for the SIMD intrinsics documented by Intel's only intrinsics finder / search tool: https://software.intel.com/sites/landingpage/IntrinsicsGuide/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With