Non-Confidential | PDF version | ARM DUI0472M | ||

| ||||

Home > Using the NEON Vectorizing Compiler > Reduction of a vector to a scalar |

A special category of scalar use within loops is reduction operations. This category involves the reduction of a vector of values down to a scalar result.

The most common reduction is the summation of all elements of a vector. Other reductions include:

The dot product of two vectors.

The maximum value in a vector.

The minimum value in a vector.

The product of all vector elements.

The index of the maximum or minimum element of a vector.

The following example shows a dot
product reduction where `x`

is a reduction scalar.

float a[99], b[99], x; int i, n; ... for (i = 0; i < n; i++) x += a[i] * b[i];

Reduction operations are worth vectorizing because they occur so often. In general, reduction operations are vectorized by creating a vector of partial reductions that is then reduced into the final resulting scalar.