Header files for x86 SIMD intrinsics

前端 未结 5 601
借酒劲吻你
借酒劲吻你 2020-11-28 17:17

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

5条回答
  •  天命终不由人
    2020-11-28 17:52

    From this page

    +----------------+------------------------------------------------------------------------------------------+
    |     Header     |                                         Purpose                                          |
    +----------------+------------------------------------------------------------------------------------------+
    | x86intrin.h    | Everything, including non-vector x86 instructions like _rdtsc().                         |
    | mmintrin.h     | MMX (Pentium MMX!)                                                                       |
    | mm3dnow.h      | 3dnow! (K6-2) (deprecated)                                                               |
    | xmmintrin.h    | SSE + MMX (Pentium 3, Athlon XP)                                                         |
    | emmintrin.h    | SSE2 + SSE + MMX (Pentium 4, Athlon 64)                                                  |
    | pmmintrin.h    | SSE3 + SSE2 + SSE + MMX (Pentium 4 Prescott, Athlon 64 San Diego)                        |
    | tmmintrin.h    | SSSE3 + SSE3 + SSE2 + SSE + MMX (Core 2, Bulldozer)                                      |
    | popcntintrin.h | POPCNT (Nehalem (Core i7), Phenom)                                                       |
    | ammintrin.h    | SSE4A + SSE3 + SSE2 + SSE + MMX (AMD-only, starting with Phenom)                         |
    | smmintrin.h    | SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE + MMX (Penryn, Bulldozer)                             |
    | nmmintrin.h    | SSE4_2 + SSE4_1 + SSSE3 + SSE3 + SSE2 + SSE + MMX (Nehalem (aka Core i7), Bulldozer)     |
    | wmmintrin.h    | AES (Core i7 Westmere, Bulldozer)                                                        |
    | immintrin.h    | AVX, AVX2, AVX512, all SSE+MMX (except SSE4A and XOP), popcnt, BMI/BMI2, FMA             |
    +----------------+------------------------------------------------------------------------------------------+
    

    So in general you can just include immintrin.h to get all Intel extensions, or x86intrin.h if you want everything, including _bit_scan_forward and _rdtsc, as well as all vector intrinsics include AMD-only ones. If you are against including more that you actually need then you can pick the right include by looking at the table.

    x86intrin.h is the recommended way to get intrinsics for AMD XOP (Bulldozer-only, not even future AMD CPUs), rather than having its own header.

    Some compilers will still generate error messages if you use intrinsics for instruction-sets you haven't enabled (e.g. _mm_fmadd_ps without enabling fma, even if you include immintrin.h and enable AVX2).

提交回复
热议问题