Search code examples
intelsimdintrinsics

How to read the "Intel Intrinsics Guide"?


I am trying to get started with AVX512 intrinsics by reading the Intel Intrinsics Guide but so far I have found that it does not define the named datatypes or the pseudocode syntax used for explanation. Without such definitions, the so-called guide is not guiding me in the least.

For example, if I look up the function _mm512_slli_epi32 (__m512i a, unsigned int imm8) which takes a vector a of packed 32-bit integers and does something to it, the guide says the result is stored in something called dst (undefined) and the operation is as follows.

FOR j := 0 to 15
    i := j*32
    IF imm8[7:0] > 31
        dst[i+31:i] := 0
    ELSE
        dst[i+31:i] := ZeroExtend32(a[i+31:i] << imm8[7:0])
    FI
ENDFOR
dst[MAX:512] := 0

What on earth am I supposed to make out of this without proper documentation? There isn't even a link to documentation on the syntax used.

Kindly help. I am looking for a guide to "Intel Intrinsics Guide". Alternatively, I would also appreciate any other pedagogical introduction to Intel intrinsics. This answer does not help. Thanks!


Solution

  • Intel calls dst the return value of the instruction. Overall, that instruction does this:

    inline std::array<int, 16> slli( std::array<int, 16> a, int imm )
    {
        for( int& tmp : a )
            tmp = ( imm > 31 ) ? 0 : tmp << imm;
        return a;
    }
    

    Here’s my article: http://const.me/articles/simd/simd.pdf I hope a good introduction.