C++ Classes and SIMD Operations
Use of C++ classes for SIMD operations allows for operating on arrays or vectors of data in a single operation. Consider the addition of two vectors,
B, where each vector contains four elements. Using an integer vector class, the elements
B[i]from each array are summed as shown in the following example.
Typical Method of Adding Elements Using a Loop
int a, b, c; for (i=0; i<4; i++) /* needs four iterations */ c[i] = a[i] + b[i]; /* computes c, c, c, c */
The following example shows the same results using one operation with an integer class.
SIMD Method of Adding Elements Using Ivec Classes
Is16vec4 ivecA, ivecB, ivec C; /*needs one iteration*/ ivecC = ivecA + ivecB; /*computes ivecC0, ivecC1, ivecC2, ivecC3 */
The Intel® C++ SIMD classes provide parallelism, which is not easily implemented using typical mechanisms of C++. The following table shows how the Intel® C++ classes use the SIMD classes and libraries.
SIMD Vector Classes