I have the following code as a part of a program, but when I compile it I get the following error:
cannot convert ‘int’ to ‘__m128i {aka __vector(2) long long int}’ in assignment
Where the code is:
int t;
int s;
__m128i *array;
__m128i vector;
posix_memalign ((void **) &array, BYTE_ALIGNMENT, n * m * sizeof(__m128i) );
int l=0;
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
array[l] = (condition) ? t : s; // fill the array elements with s or t
l++;
}
}
vector = _mm_load_si128( &array[index]);
The problem is in this line
array[l] = (condition) ? t : s;
I have found the instruction __m128i _mm_cvtsi32_si128(int a)
but unfortunately, it is used for 32-bits elements only, while I have 16-bit elements (vector of size 8).
Finally, i found this update is working properly
int t;
int s;
int16_t *array;
__m128i vector;
posix_memalign ((void **) &array, BYTE_ALIGNMENT, n * m * sizeof(int16_t) );
int l=0;
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
array[l] = (condition) ? t : s; // fill the array elements with s or t
l++;
}
}
vector = _mm_load_si128( (__m128i*)&array[index]);
Thanks for you all