Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

Need help, SIMD guru

Timocafe
Beginner
537 Views
Hello All,
I am coding a SIMD program (under AMS), I do not succeed my final arrangement of one of
my xmm register. In this 128 bits register, I have 4 double words (int) like that :
AB C D
I would like reorder the register like that :
0 A B C
it seems to be the asm pshufd xmm, xmm, imm8. But I do not find the magical value at imm8, although
I read ten times the doc ...
Thank you
Tim
0 Kudos
1 Solution
Matthias_Kretz
New Contributor I
537 Views
It is much easier to shift in this case (and the correct direction depends on whether you noted memory order or order inside the register - which is just the opposite thanks to little endian x86...)

v = _mm_slli_si128(v, 4); // shift the contents of v to the left by 4 bytes

or

v = _mm_srli_si128(v, 4); // shift to the right by 4 bytes

The little endian confusion is probably also what makes it so hard to get the correct number for pshufd...

View solution in original post

0 Kudos
4 Replies
Matthias_Kretz
New Contributor I
538 Views
It is much easier to shift in this case (and the correct direction depends on whether you noted memory order or order inside the register - which is just the opposite thanks to little endian x86...)

v = _mm_slli_si128(v, 4); // shift the contents of v to the left by 4 bytes

or

v = _mm_srli_si128(v, 4); // shift to the right by 4 bytes

The little endian confusion is probably also what makes it so hard to get the correct number for pshufd...
0 Kudos
Timocafe
Beginner
537 Views
Thank you very much, it works. As it was a Microsoft specific "functions", I believed it will not work under GCC or ICC. Do we get a convergence between Microsoft/Intel/AMD SIMD ? My reference book is the software
Vectorization handbook it is on intel SSE2 that why I do not find the reference if this function.
Regard's
Tim
0 Kudos
Nicolae_P_Intel
Employee
537 Views

As these are intrinsics they should work under any of these compilers (MSVC, ICC or GCC) without problems. However, as you go to the latest and greatest intrinsics the compiler support will probably differ but eventually all compilers will end up addingthat support (just at different points in time).

0 Kudos
TimP
Honored Contributor III
537 Views
There are differences among the compilers in flexibility of syntax. For example, Intel supports some nesting of intrinsics which Microsoft doesn't, while gcc is more flexible about 128-bit integer usage. Intel compilers have dropped as there no longer is support for SSE without SSE2.
I think a few cases which Microsoft supported but Intel didn't were in line to be fixed.
0 Kudos
Reply