1

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 :/

Z boson
  • 32,619
  • 11
  • 123
  • 226
user81993
  • 6,167
  • 6
  • 32
  • 64
  • unless there is a fused-multiply-subtract, you'll need a separate negation. But that instruction would be simple and fast so you might not see the decrease in speed – phuclv May 08 '15 at 09:57

0 Answers0