Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 3384

Using arithmetic or logical operators with SIMD data types

$
0
0

Intel C++ compiler started to support arithmetic or logical operators for SIMD data types, since version 15.0.  The advantages of SIMD operator support include improvements in ease of coding and readability of code.  Users may simply write m3 = m1 + m2, instead of writing an intrinsic _mm256_add_pd, in order to add two 256-bit double precession floating point vectors.

In ICC 15.0, SIMD data types supported are floating point only, including __m128, __m128d, __m256 and __m256d.  Integer data types are not supported.  Intel may extend the support to 512-bit SIMD data types in the future.

Here is an example demonstrating arithmetic and logical operators with SIMD data types.

#include <immintrin.h>

void main()
{
    __m128  a1, a2;
    __m128d b1, b2;
    __m256  x1, x2;
    __m256d y1, y2;

    // arithmetic operations
    a1 = a1 + a2;
    b1 *= -b2;
    x1 = x1 / x2;
    y1 *= y2;

    // logical operations
    a1 = a1 | a2;
    b1 |= b2;
    x1 = x1 & x2;
    y1 &= y2;
}

 


Viewing all articles
Browse latest Browse all 3384

Trending Articles



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