We're trying to make a vector intrinsic library of different operations and one of them is getting the absolute value of the number. However, my professor limited it to double
only.
I'm fairly new to the x86 intrinsics instruction set, so I was hoping someone can enlighten me.
This is what I have so far:
void vectorAbs(double *x, double *y, unsigned int N);
int main()
{
double x[] = { -1, -2, -3, -4, -5, -6 };
double y[] = { 2, 2, 2, 2, 2, 2 };
double *pX = x, *pY = y;
vectorAbs(pX, pY, 6);
}
void vectorAbs(double *x, double *y, unsigned int N)
{
__m128d xVar;
__m128d yVar;
printf("\nSquare of x : \n");
for (int i = 0; i < N; i += 2)
{
xVar = _mm_loadu_pd(&x[i]); // load *x[i] to xVar
yVar = _mm_abs_epi16(xVar); // abs of x
_mm_storeu_pd(&y[i], yVar); // store yVar to y[i]
printf("%lf, %lf, ", y[i], y[i + 1]);
}
system("pause");
}
And the error I'm getting is:
no operator "=" matches these operands
operand types are: __m128d = __m128i