Working with c++ AMP, I'm trying to optimize my math functions. Ran into a bit of a conundrum with cross product:
float_3 CrossProduct(float_3 v1, float_3 v2) restrict(amp) {
float a = mad(v1.y, v2.z, -v1.z * v2.y);
float b = mad(v1.z, v2.x, -v1.x * v2.z);
float c = mad(v1.x, v2.y, -v1.y * v2.x);
return float_3(a, b, c);
}
So as you can see, I had to flip the sign of the accumulate argument. Is there still any performance gains from this? Does the - count as an extra instruction?
The benchmark I ran on it doesn't seem to have improved in speed :/