# Multiply-accumulate: Wikis

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

# Encyclopedia

In computing, especially digital signal processing, multiply-accumulate is a common operation that computes the product of two numbers and adds that product to an accumulator.

$\ a \leftarrow a + ( b \times c )$

When done with floating point numbers it might be performed with two roundings (typical in many DSPs) or with a single rounding. When performed with a single rounding, it is called a fused multiply-add (FMA) or fused multiply-accumulate (FMAC).

Modern computers may contain a dedicated multiply-accumulate unit, or MAC unit, consisting of a multiplier implemented in combinational logic followed by an adder and an accumulator register which stores the result when clocked. The output of the register is fed back to one input of the adder, so that on each clock the output of the multiplier is added to the register. Combinational multipliers require a large amount of logic, but can compute a product much more quickly than the method of shifting and adding typical of earlier computers. The first processors to be equipped with MAC-units were digital signal processors, but the technique is now also common in general-purpose processors.

## In floating-point arithmetic

When done with integers, the operation is typically exact (computed modulo some power of 2). However, floating-point numbers have only a certain amount of mathematical precision. That is, digital floating-point arithmetic is generally not associative or distributive. (See Floating point#Accuracy problems.)

Therefore, it makes a difference to the result whether the multiply-add is performed with two roundings, or in one operation with a single rounding. When performed with a single rounding, the operation is termed a fused multiply-add.

A fused multiply-add is a floating-point multiply-add operation performed in one step, with a single rounding. That is, where an unfused multiply-add would compute the product b×c, round it to N significant bits, add the result to a, and round back to N significant bits, a fused multiply-add would compute the entire sum a+b×c to its full precision before rounding the final result down to N significant bits.

A fast FMA can speed up and improve the accuracy of many computations which involve the accumulation of products:

When implemented inside a microprocessor, this can actually be faster than a multiply operation followed by an add, even though standard industrial implementations based on the original IBM RS/6000 design require a 2N-bit adder to compute the sum properly.[1]

A useful benefit of including this instruction is that it allows an efficient software implementation of division and square root operations, thus eliminating the need for dedicated hardware for those operations.

The FMA operation is included in IEEE 754-2008.

The 1999 standard of the C programming language supports the FMA operation through the fma standard math library function.

The fused multiply-add operation was introduced as multiply-add fused in the IBM POWER1 processor (1990),[2] but has been added to numerous other processors since then:

It will be implemented in AMD processors with FMA4 support. Intel plans to implement FMA3 in processors using its Haswell microarchitecture, due sometime in 2012.[4]

FMA capability is also present in the NVIDIA GeForce 200 Series (GTX 200) GPUs, GeForce 300 Series GPUs and the NVIDIA Tesla C1060 Computing Processor & C2050 / C2070 GPU Computing Processor GPGPUs.[5] FMA has been added to the AMD Radeon line with the 5x00 series.[6]

## References

1. ^ Bridged Floating-Point Fused Multiply-Add Design Eric Quinnell et al, undated, circa 2006
2. ^ Montoye, R. K.; Hokenek, E.; Runyon, S. L. (January 1990), "Design of the IBM RISC System/6000 floating-point execution unit", IBM Journal of Research and Development 34 (1): 59–70, ISSN 0018-8646
3. ^ http://www.mdronline.com/mpr/h/2008/1103/224401.html - Godson-3 Emulates x86: New MIPS-Compatible Chinese Processor Has Extensions for x86 Translation