我将以下代码作为程序的一部分,但是当我编译它时,我收到以下错误:
cannot convert ‘int’ to ‘__m128i {aka __vector(2) long long int}’ in assignment
代码是:
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]);
问题出在这一行
array[l] = (condition) ? t : s;
我找到了__m128i _mm_cvtsi32_si128(int a)
指令但不幸的是,它只用于32位元素,而我有16位元素(向量大小为8)。
答案 0 :(得分:0)
最后,我发现此更新工作正常
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]);
谢谢大家