Skip to content
p0nce edited this page Aug 4, 2021 · 11 revisions

Contributing guidelines

Welcome to intel-intrincs! This is a fun, but very detailed-oriented library to contribute for.

Order of intrinsics

Intrinsics should be sorted in a file in the same order as the Intel Intrinsics Guide:

Order of implementation

Intrinsics should always work with all compilers, in x86 32-bit and 64-bit targets. Often, the implementation of intrinsics can be shared between compilers, but often it cannot.

static if(DMD_with_DSIMD) // DMD D_SIMD version, currently disabled. To test it, turn `SSESizedVectorsAreEmulated` to false;
{
    // DMD D_SIMD implementation
}
else static if(GDC_with_SSE2) // GDC version 
{
    // GDC x86_64 implementation
}
else static if (LDC_with_SSE2)
{
    // LDC implementation
}
else static if (LDC_with_ARM64)
{
    // ARM64 + LDC implementation
}
else static if (LDC_with_ARM32)
{
    // (optional) If you are interested in ARM32.
}
else
{
    // Fallback implementation, 
    // used by DMD and GDC x86 implementation
    // Also used by LDC and GDC with the instruction sets disabled.
}
unittest
{
   // Same test for every compiler
}

Testing

All new or touched intrinsics should be covered by unittests.

Finer points

  • Use vec.ptr[ind] = stuff; for assignment of one vector element, as this keeps compatibility with the older GDC found in Travis CI.
  • Using intel-intrinsics should not lead to MMX instructions being generated (as it incurs annoying FPU/MMX transitions). Often, a reasonably fast equivalent exist using higher intruction sets.
  • When you use a builtin, make sure it exists over a large range of existing LDC versions. When it does and is a right call, do use it though.
  • nothrow @nogc. All new intrinsics should be as @trusted if possible, if they they cannot produce a memory safety error. This is WIP. Getting @safe is rarely possible because of the many implementation pathes.
  • Basically, it's best to test every path in https://d.godbolt.org/

Conditions for merging

To be merged a PR:

  • need one unittest per intrinsic
  • need a slow path that works on all compilers
  • fast paths (actual intrinsics) can be added later, but is probably your real interest ^^
  • follows recommendations on this page.