Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 11/07/2023
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

FMA and NOFMA

General Compiler Directives: Tells the compiler to allow generation of fused multiply-add (FMA) instructions, also known as floating-point contractions. NOFMA disables the generation of FMA instructions.

!DIR$ FMA

!DIR$ NOFMA

These directives affect the current program unit but they also apply to subsequent program units in the source file, unless and until a program unit containing another FMA or NOFMA directive is encountered.

Once a NOFMA directive has been specified, it is in effect from that point forward. The setting impacts later routines in the source file. For example, consider that the following are in the same source file:

    real function fms_mul2( a,  b,  c,  d)
      implicit none
      real :: a, b, c, d
!       the default !dir$ fma leads to fma generation:
!       this is transformed into FMS(a,b,FMA(c,d,0)) 

!dir$ nofma 
      fms_mul2 = a*b - c*d                ! no fma generation here
    end function fms_mul2

    real function fms_mul( a,  b,  c,  d)
      implicit none
      real :: a, b, c, d
      fms_mul = (a*b) - (c*d)             ! no fma generation here
    end function fms_mul

The NOFMA directive specified in fms_mul2 will also impact the routine fms_mul. You must explicitly specify the FMA directive to override the effect of the NOFMA directive.