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.

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

Example

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 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.

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.

Example

#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; 
}

This loop requires the parallel option in addition to the ivdep pragma to indicate there is no loop-carried dependencies:

Example

#pragma ivdep 
  for (j=0; j<n; j++) { a[b[j]] = a[b[j]] + 1; }

This loop requires the parallel option in addition to the ivdep pragma to ensure there is no loop-carried dependency for the store into a().

For more complete information about compiler optimizations, see our Optimization Notice.