Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

Use of C++ Classes for SIMD Operations on Intel® Many Integrated Core Architecture (Intel® MIC Architecture)

$
0
0

This topic only applies to Intel® Many Integrated Core Architecture (Intel® MIC Architecture).

The use of C++ classes for SIMD operations on Intel® MIC Architecture is based on the concept of operating on arrays, or vectors of data, in parallel.

Consider the addition of two vectors, A and B, where each vector contains sixteen elements. Using integer vector class, the elements A[i] and B[i] from each array are summed as shown in the following example.

Typical Method of Adding Elements Using a Loop

int a[16], b[16], c[16];
for (i=0; i<16; i++) /* needs sixteen iterations */
c[i] = a[i] + b[i]; /* returns c[0], c[1], c[2], c[3], …, c[15] */

SIMD Method of Adding Elements Using Ivec Classes

The following example shows the same results using one operation with integer vector Classes.

Is32vec16 ivecA, ivecB, ivec C; /*needs one iteration */
ivecC = ivecA + ivecB; /*returns 16 elements inside ivecC  */

Available Classes

These C++ classes provide parallelism, which is not easily implemented using typical mechanisms of C++. The following table provides details of these class libraries.

Instruction SetClassSignednessData TypeSizeElementsHeader File

Intel® Initial Many Core Instructions (Intel® IMCI)

F64vec8

unspecified

double648micvec.h
F32vec16

unspecified

float3216micvec.h
M512

unspecified

__m5125121micvec.h
I64vec8

unspecified

long int648micvec.h
I32vec16

unspecified

int3216micvec.h
Is32vec16

signed

int3216micvec.h
Iu32vec16

unsigned

int3216micvec.h

Most classes contain similar functionality for all data types and are represented by all available intrinsics. However, some capabilities do not translate from one data type to another without suffering from poor performance, and are therefore excluded from individual classes. The I64vec8 class currently supports logical and data manipulation operations but not arithmetic operations.

Note

Intrinsics that take immediate values and cannot be expressed easily in classes are not implemented.

Accessing the Classes Using a Header File

The required class header files are installed in the include directory with the compiler. To enable the classes, use the #include directive in your program file as shown below:

 #include <micvec.h>

Note

You can enable these classes within native code or within offloaded code that is written to contain target-specific code typically protected by the __MIC__ macro.

Inglés

Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>