Description

Reuse your C++ SIMD code using Intel intrinsics syntax. Works with LDC.

Package Information

Version1.0.3 (2017-Mar-06)
Repository https://github.com/p0nce/intel-intrinsics
LicenseBSL-1.0
CopyrightGuillaume Piolat 2016
Registered byponce
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

intel-intrinsics

The goal is to allow you to use Intel intrinsics in D code.

Why Intel intrinsic syntax? Because it is more familier to C++ programmers and there is a convenient online guide provided by Intel: https://software.intel.com/sites/landingpage/IntrinsicsGuide/

For now only LDC is supported. But be sure to know about the superior SIMD capabilities of LDC exposed in ldc.simd.

Usage


import inteli.xmmintrin; // allows SSE1 intrinsics
import inteli.emmintrin; // allows SSE2 intrinsics

// distance between two points in 4D
float distance(float[4] a, float[4] b) nothrow @nogc
{
    __m128 va = _mm_loadu_ps(a.ptr);
    __m128 vb = _mm_loadu_ps(b.ptr);
    __m128 diffSquared = _mm_sub_ps(va, vb);
    diffSquared = _mm_mul_ps(diffSquared, diffSquared);
    __m128 sum = _mm_add_ps(diffSquared, _mm_srli_si128!8(diffSquared));
    sum = _mm_add_ps(sum, _mm_srli_si128!4(sum));
    return _mm_cvtss_f32(_mm_sqrt_ss(sum));
}
assert(distance([0, 2, 0, 0], [0, 0, 0, 0]) == 2);

Supported instructions set

  • SSE1
  • SSE2

Available versions

1.0.3 1.0.2 1.0.1 1.0.0 ~master