omp simd early_exit
Extends #pragma omp simd, allowing vectorization of multiple exit loops.
Extends #pragma omp simd allowing vectorization of multiple exit loops. When this clause is specified:
- Each operation before last lexical early exit of the loop may be executed as if early exit were not triggered within the SIMD chunk.
- After the last lexical early exit of the loop, all operations are executed as if the last iteration of the loop was found.
- Each list item specified in the linear clause is computed based on the last iteration number upon exiting the loop.
- The last value for linear clauses and conditional lastprivates clauses are preserved with respect to scalar execution.
- The last value for reductions clauses are computed as if the last iteration in the last SIMD chunk was executed up on exiting the loop.
- The shared memory state may not be preserved with regard to scalar execution.
- Exceptions are not allowed.
The following example demonstrates how to use this pragma.
In the following example, the pragma specifies that the vector execution of the
forloop is safe even though the loop may exit before the loop upper bound condition
j < ubbecomes false. Suppose
j1is the smallest
ub, such that
b[j] <= 0. If
j1+2, … are within the same (last) SIMD chunk, read of
b[j1+2], … and the subsequent evaluation of
<= 0will happen unconditionally, unlike the scalar execution of the same loop. Safety of such vector evaluation is programmer's responsibility. If necessary,
simdlen()clause can be used to control the SIMD chunk size.