samedi 25 février 2017

C++ SIMD: Store uint64_t value after bitwise and operation

I am trying to do a bitwise & between elements of two arrays of uint64_t integers and then store the result in another array. This is my program:

#include <emmintrin.h>
#include <nmmintrin.h>
#include <chrono>


int main()
{

  uint64_t data[200];
  uint64_t data2[200];
  uint64_t data3[200];
  __m128i* ptr = (__m128i*) data;
  __m128i* ptr2 = (__m128i*) data2;
  uint64_t* ptr3 = data3;

  for (int i = 0; i < 200; ++i, ++ptr, ++ptr2, ptr3 += 2)
    _mm_store_ps(ptr3, _mm_and_si128(*ptr, *ptr2));

}

However, I get this error:

test.cpp:17:50: error: cannot convert ‘uint64_t* {aka long unsigned int*}’ to ‘float*’ for argument ‘1’ to ‘void _mm_store_ps(float*, __m128)’
     _mm_store_ps(ptr3, _mm_and_si128(*ptr, *ptr2));

For some reason, the compiler thinks I'm copying to an array of floats. Is it possible to do what I am trying to do with arrays of uint64_t?

Aucun commentaire:

Enregistrer un commentaire