Intel intrinsics函数-SSE、AVX、MMX等指令集简单介绍

MMX指令集支持多种整数类型的运算。MMX定义了64位紧缩整数类型,,对应Intrinsic中的__m64类型,它能一次能处理2个32位整数。

  • —64-bit的MMX寄存器(8个,复用了浮点寄存器的尾部,与x87共用寄存器,缺少浮点指令)
  • —支持在打包的字,字节,双字整数上的SIMD操作
  • —MMX指令用于多媒体和通讯软件

SSE是MMX的超集。SSE指令集只支持单精度浮点运算,直到SSE2指令集才支持双精度浮点数运算。SSE2定义了128位紧缩整数类型,对应Intrinsic中的__m128i类型,它能一次能处理4个32位整数。

  • —包括了70条指令,其中50条SIMD浮点运算指令、12条MMX 整数运算增强指令、8条内存连续数据块传输指令
  • —新增8个XMM寄存器(XMM0-XMM7)
  • —在X86_64中额外增加8个(XMM8-XMM15)
SSE2指令集:

  • —使用了144个新增指令
  • —从64位扩展到了128 位
  • —提供双精度操作支持

—SSE3指令集:

  • —增加13条指令(允许寄存器内部之间运算,浮点数到整数的转换)
  • —超线程性能增强指令可以提升处理器的超线程处理能力

—SSSE3指令集:

  • —扩充了SSE3,增加16条指令
  • —绝对值、相反数等

—SSE4指令集:

  • —新增47条指令,更新至SSE4.2

AVX指令集只支持单精度和双精度浮点运算。2013年Haswell架构中的AVX2指令集才支持整数运算。

  • —数据宽度从128位扩展为256位
  • —操作数从两个增加到三个

 

Compiler Auto Vectorization

-x flag, which tells the compiler to generate specific vectorization instructions.
Using the -xHost flag enables the highest level of vectorization supported on the processor on which the user compiles. Note that the Intel compiler will try to vectorize a code with SSE2 instructions at optimizations of -O2 or higher. Disable this by specifying -no-vec.
The Intel compiler can generate a single executable with multiple levels of vectorization with the -ax flag, which takes the same options as the -x flag (i.e., AVX, …, SSE2). This flag will generate run-time checks to determine the level of vectorization support on the processor and will then choose the optimal execution path for that processor. It will also generate a baseline execution path that is taken if the -ax level of vectorization specified is not supported.
-vec-report flag, which generates diagnostic information regarding vectorization to stdout. The -vec-report flag takes an optional parameter that can be a number between 0 and 5 (e.g., -vec-report0), with 0 disabling diagnostics and 5 providing the most detailed diagnostics about what loops were optimized, what loops were not optimized, and why those loops were not optimized.
Intel intrinsics guide:
https://software.intel.com/sites/landingpage/IntrinsicsGuide/

Leave a Reply

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