Intel® C++ Compiler 16.0 User and Reference Guide

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(n)

Specifies how many nested loops of a for loop associated with the OpenMP* for construct should be collapsed into a single loop for running in parallel.

firstprivate( list )

Provides a superset of the functionality provided by the private clause. Each private data object is initialized with the value of the original object.

lastprivate( list )

Provides a superset of the functionality provided by the private clause. When exiting the region, the original object is updated with the value of the private copy from the last sequential iteration of the associated loop, or the lexically last section construct.

nowait

Indicates that an implementation may omit the barrier at the end of the worksharing region.

ordered

private( list )

Declares variables to be private to each thread in a team.

reduction( operator: list )

Performs a reduction on scalar variables.

schedule (type[, chunk])

Specifies how iterations of the for loop are divided among the threads of the team.

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