Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 3/22/2024
Public

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

Document Table of Contents

ivdep

Instructs the compiler to ignore assumed vector dependencies.

Syntax

#pragma ivdep

Arguments

None

Description

The ivdep pragma instructs the compiler to ignore assumed vector dependencies. To ensure correct code, the compiler treats an assumed dependence as a proven dependence, which prevents vectorization. This pragma overrides that decision. Use this pragma only when you know that the assumed loop dependencies are safe to ignore.

The ivdep pragma is supported in host code only.

In addition to the ivdep pragma, the vector pragma can be used to override the efficiency heuristics of the vectorizer.

NOTE:

The proven dependencies that prevent vectorization are not ignored, only assumed dependencies are ignored.

Examples

The loop in this example will not vectorize without the ivdep pragma, since the value of k is not known; vectorization would be illegal if k < 0:

void ignore_vec_dep(int *a, int k, int c, int m) {
#pragma ivdep
for (int i = 0; i < m; i++)
  a[i] = a[i + k] * c; 
}

The pragma binds only the for loop contained in current function. This includes a for loop contained in a sub-function called by the current function:

#pragma ivdep 
for (i=1; i<n; i++) {
  e[ix[2][i]] = e[ix[2][i]]+1.0;
  e[ix[3][i]] = e[ix[3][i]]+2.0; 
}