AVX - Vector shifts

AVX - Vector shifts

Ritratto di ale

I'm comparing two programmes, one is written using SSE and the other one AVX. My aim is to show that the avx version is running 2 times faster but I'm loosing something like 20 % with some shift operations.

I need to perform quite often a shift operation to rotate an Avx Vector 1 byte on the left. It seems like all the instructions I need will only be available with AVX2.

Actually I'm splitting the source _m256i vector into 2 _128i but  this way I'm loosing performances. Is there any other way to perform this operation? Why shifting operation were not included in avx instruction set?

Thanks in advance for your help, here's the current version on my code

  a1 = _mm256_castsi256_si128( _source );
  a2 = _mm256_extractf128_si256 ( _source,1 );
  
  b1 = _mm_slli_si128( a1,1);
  b2 = _mm_slli_si128( a2,1);
  a1 = _mm_srli_si128( a1,15);
  a2 = _mm_srli_si128( a2,15);
  
   _dest  =  _mm256_castsi128_si256 ( _mm_or_si128(b1,a2) );
   _dest =  _mm256_insertf128_ps (  _dest, _mm_or_si128(b2,a1), 1 );

2 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di Thomas Willhalm (Intel)

Yes, Intel AVX supports only FP instructions for 256bit. If you need other instructions, like the shift that you are describing, it is better to use the 128bit instructions. You might save some instructions because of the non-destructive source that comes with AVX, but that's about it. For integer instructions with 256bit registers, you will have to wait for AVX2.

Accedere per lasciare un commento.