Developer Guide and Reference

Contents

Programming Guidelines for Vectorization

The goal of including the vectorizer component in the Intel®
C++
Compiler is to exploit single-instruction multiple data (SIMD) processing automatically. Users can help by supplying the compiler with additional information; for example, by using auto-vectorizer hints or
pragmas
.
Using this option enables vectorization at default optimization levels for both Intel® microprocessors and non-Intel microprocessors. Vectorization may call library routines that can result in additional performance gain on Intel® microprocessors than on non-Intel microprocessors.
The vectorization can also be affected by certain options, such as
/arch
(Windows*),
-m
(Linux*
and
macOS*
), or
[Q]x
.

Guidelines to Vectorize Innermost Loops

Follow these guidelines to vectorize innermost loop bodies.
Use:
  • straight-line code (a single basic block)
  • vector data only; that is, arrays and invariant expressions on the right hand side of assignments.
    Array references can appear on the left hand side of assignments.
  • only assignment statements.
Avoid:
  • function calls (other than math library calls)
  • non-vectorizable operations (either because the loop cannot be vectorized, or because an operation is emulated through a number of instructions)
  • mixing vectorizable types in the same loop (leads to lower resource utilization)
  • data-dependent loop exit conditions (leads to loss of vectorization)
To make your code vectorizable, you will often need to make some changes to your loops. You should only make changes needed to enable vectorization, and avoid these common changes:
  • loop unrolling, which the compiler performs automatically
  • decomposing one loop with several statements in the body into several single-statement loops

Restrictions

There are a number of restrictions that you should consider. Vectorization depends on two major factors: hardware and style of source code.
<