Suvarna Garge (Editor)

FMA instruction set

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The FMA instruction set is an extension to the 128 and 256-bit Streaming SIMD Extensions instructions in the x86 microprocessor instruction set to perform fused multiply–add (FMA) operations. There are two variants:

Contents

  • FMA4 is supported in AMD processors starting with the Bulldozer architecture. FMA4 was realized in hardware before FMA3.
  • FMA3 is supported in AMD processors starting with the Piledriver architecture and Intel starting with Haswell processors and Broadwell processors since 2014.
  • New instructions

    FMA3 and FMA4 instructions have almost identical functionality but are not compatible. Both contain fused multiply–add (FMA) instructions for floating point scalar and SIMD operations, but FMA3 instructions have three operands while FMA4 ones have four. The FMA operation has the form d = round(a × b + c) where the round function performs a rounding to allow the result to fit within the destination register if there are too many significant bits to fit within the destination.

    The four-operand form (FMA4) allows a, b, c and d to be four different registers, while the three-operand form (FMA3) requires that d be the same register as a, b or c. The three-operand form makes the code shorter and the hardware implementation slightly simpler while the four-operand form provides more programming flexibility.

    See XOP instruction set for more discussion of compatibility issues between Intel and AMD.

    CPUs with FMA3

  • Intel
  • Intel introduced hardware FMA3 in processors based on Haswell during 2013.
  • AMD
  • AMD introduced FMA3 support in processors starting with Piledriver architecture for compatibility reasons. The 2nd generation APU processors based on "Trinity" (32nm) supporting FMA3 instructions were launched May 15, 2012. The 2nd generation Bulldozer processors with Piledriver cores supporting FMA3 instructions were launched October 23, 2012.
  • CPUs with FMA4

  • AMD
  • Bulldozer processor core - was launched October 12, 2011.
  • Piledriver
  • Intel
  • It is uncertain whether future Intel processors will support FMA4, due to Intel's announced change to FMA3.
  • History

    The incompatibility between Intel's FMA3 and AMD's FMA4 is due to both companies changing plans without coordinating coding details with each other. AMD changed their plans from FMA3 to FMA4 while Intel changed their plans from FMA4 to FMA3 almost at the same time. The history can be summarized as follows:

  • August 2007: AMD announces the SSE5 instruction set, which includes 3-operand FMA instructions. A new coding scheme (DREX) is introduced for allowing instructions to have three operands.
  • April 2008: Intel announces their AVX and FMA instruction sets, including 4-operand FMA instructions. The coding of these instructions uses the new VEX coding scheme, which is more flexible than AMD's DREX scheme.
  • December 2008: Intel changes the specification for their FMA instructions from 4-operand to 3-operand instructions. The VEX coding scheme is still used.
  • May 2009: AMD changes the specification of their FMA instructions from the 3-operand DREX form to the 4-operand VEX form, compatible with the April 2008 Intel specification rather than the December 2008 Intel specification.
  • October 2011: AMD Bulldozer processor supports FMA4.
  • January 2012: AMD announces FMA3 support in future processors codenamed Trinity and Vishera; they are based on the Piledriver architecture.
  • May 2012: AMD Piledriver processor supports both FMA3 and FMA4.
  • June 2013: Intel Haswell processor supports FMA3.
  • AMD explicitly revealed that Zen, its 3rd-generation x86-64 architecture in its first iteration (znver1 – Zen, version 1); would drop support for FMA4 in a patch to the GNU Binutils package. There has been initial confusion regarding whether FMA4 was implemented or not due to errata in the initial patch that has since then been rectified.

    Compiler and assembler support

    Different compilers provide different levels of support for FMA4:

  • GCC supports FMA4 with -mfma4 since version 4.5.0 and FMA3 with -mfma since version 4.7.0.
  • Microsoft Visual C++ 2010 SP1 supports FMA4 instructions.
  • Microsoft Visual C++ 2012 supports FMA3 instructions (if the processor also supports AVX2 instruction set extension).
  • Microsoft Visual C++ 2013
  • Microsoft Visual C++ 2015
  • PathScale supports FMA4 with -mfma.
  • LLVM 3.1 adds FMA4 support, along with preliminary FMA3 support.
  • Open64 5.0 adds "limited support".
  • Intel compilers support only FMA3 instructions.
  • NASM supports FMA3 instructions since version 2.03 and FMA4 instructions since 2.06.
  • Yasm supports FMA3 instructions since version 0.8.0 and FMA4 instructions since version 1.0.0.
  • FASM supports both FMA3 and FMA4 instructions.
  • References

    FMA instruction set Wikipedia