[英]converting from int to (16-bit) __m128i
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). 我发现了指令__m128i _mm_cvtsi32_si128(int a)
但不幸的是,它仅用于32位元素,而我只有16位元素(大小为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 谢谢大家
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.