I have the following method which calcualtes the dot product of the given arrays:
static double DotProduct(uint[] vecA, uint[] vecB)
{
double dotProduct = 0;
for (var i = 0; i < vecA.Length; i++)
{
dotProduct += (vecA[i] * vecB[i]);
}
return dotProduct;
}
I want to improve upon this and utilize SIMD and AVX. My attempt of vectorizing this as follows throws an ArgumentOutOfRange exception:
static double DotProduct(uint[] vecA, uint[] vecB)
{
Vector<uint> vec1 = new Vector<uint>(vecA);
Vector<uint> vec2 = new Vector<uint>(vecB);
return Vector.Dot(vec1, vec2);
}
What am I missing?