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!
imm8[7:0]
,dst[i+31:i]
anddst[MAX:512]
refer to bit ranges within operands. Anything else? – DartboardZeroExtend32
should be pretty self-explanatory. – Sagabegin
andend
required at every block (at least, if it is more than one line). This is essentially some pseudo code -- maybe mostly "BASIC"-style (which has thousands of dialects, though). – EsemplasticZeroExtend32
do? You see that is my point. It seems to be written only for experts. Where does a beginner begin? – FusiformZeroExtend32
is there. – DartboardZeroExtend
notZeroExtend32
, e.g. for thepslld
entry. The asm manual has a diagram; if you ever find the intrinsics guide not clear, check the asm manual. But this seems clear enough to me, especially given the known fact that this is a SIMD left shift of separate elements (as described by the name and the English text), so bits can't shift between element boundaries. – Saga32*imm8[3:0]
when shifting by 32-bit elements and64*imm8[2:0]
when shifting by 64-bit elements and sometimes without any indexing at all? And what is the meaning ofimm8[7:0] > 31
in the above instruction? Thanks a ton! Appreciate it. – Fusiformimm8[7:0] > 31
is checking the whole 8-bit count for being greater than 31. If so, it's like it shifts out all the bits, leaving 0. i.e. it saturates the shift count instead of masking it like scalar integer shifts (likeshl
). As for32*imm8[3:0]
, that's treating the low 4 bits as an integer and multiplying it by 32. Where are you seeing that? It's not in the pseudocode forpslld
, but presumably the high bits are irrelevant for whatever operation you found this in. – Sagaimm8
supposed to be 32 bits wide? I got the other index ranges in the functions_mm512_alignr_epi32
and_mm512_alignr_epi64
. Taking only a partial range would change the number, no? I am sorry if I am being stupid. – Fusiformimm8
is 8 bits wide (1 byte). That's what the8
means; pretty much any time a name ends with a number (likerel8
orimm32
), it's a bit width. – Sagaalignr_epi32
shifts in units of 32-bit elements, so you can express it as a bit-shift bycount*32
. And the number of bits it needs to look at is determined by the number of elements in the full vector. – Saga