omp simd

Transforms the loop into a loop that will be executed concurrently using Single Instruction Multiple Data (SIMD) instructions.


#pragma omp simd [clause[, clause ...]]




Can be any of the following clauses:

  • aligned(list[:linear-step])

  • collapse(n)

  • lastprivate(list)

  • linear(list[:linear-step])

  • private(list)

  • reduction(operator:list)

  • safelen(length)

for loop

Must be in the following form:

for (init-expr; test-expr; incr-expr)



The simd construct enables the execution of multiple iterations of the associated loops concurrently by means of SIMD instructions. The integer used in the collapse clause indicates how many loops are associated with the simd construct. If the nocollapse clause is present, then only the immediately following loop is associated. No intervening code or OpenMP* constructs may appear between the for-loops.

Example: Creating two loops with SIMD instructions

#pragma omp simd collapse(2)
for(i=0; i<N; i++) { a[i] = b[i] * c[i];
   for(i=0; i<N; i++) { d[i] = e[i] * f[i]; }

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