omp for simd

Specifies the beginning of a loop that can be executed concurrently using Single Instruction Multiple Data (SIMD) instructions. Each iteration of the loop is executed by one of the threads in the team.

Syntax

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

for loops

Arguments

clause

Can be any of the following clauses:

  • collapse()

  • firstprivate( list )

  • lastprivate( list )

  • nowait

  • ordered

  • private( list )

  • reduction( operator: list )

  • schedule (type[, chunk])

for loop

Must be in the following form:

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

structured-block

Description

This pragma converts the associated for loop to a SIMD loop in a way that is consistent with any clauses that apply to the simd construct. The resulting SIMD chunks and any remaining iterations will be distributed across the implicit tasks of the parallel region in a way that is consistent with any clauses that apply to the for construct.

Example: Compiling a loop with SIMD instructions

#pragma omp for simd schedule(static,10) {
   for (i=0; i<N; i++) { a[i] = b[i] * c[i]; }
}
For more complete information about compiler optimizations, see our Optimization Notice.