Intel® C++ Compiler 16.0 User and Reference Guide
Vectorization is a key component of Intel Cilk Plus technology. SIMD Vectorization is discussed in some depth in the User-mandated or SIMD Vectorization section of the Auto-vectorization key feature chapter and the simd pragma is documented in the Pragmas section of the Compiler reference Chapter.
In this section we introduce the _Simd keyword which provides an alternative to the simd pragma. Just like the simd pragma, the _Simd keyword modifies a serial for loop for vectorization. The syntax is as follows:
_Simd [_Safelen(constant-expression)][_Reduction (reduction-identifier : list)]
The _Simd keyword and any clauses should come after the for keyword as in this example:
for _Simd (int i=0; i<10; i++){
// loop body
}
The _Simd keyword can also be used with cilk_for. See the cilk_for keyword documentation for a discussion of the cases where they are most effectively used together.
Differences between the simd pragma and _Simd keyword:
float add_floats(float *a, float *b, int n){
int i=0;
int j=0;
float sum=0;
for _Simd _Reduction(+:sum) (i=0; i<n; i++, j+=2){
a[i] = a[i] + b[j];
sum += a[i];
}
return sum;
}
To ensure that your loop is vectorized keep the following in mind: