I am hunting down some numerical issue with my application between two commits. I narrow it down to the following function:
__device__ __forceinline__ Vector2f
rotate(const Vector2f& v1, const Vector2f& v2) {
Vector2f out {v2.x() * v1.x() + v2.y() * v1.y(), -v2.y() * v1.x() + v2.x() * v1.y()};
return out;
}
where the input/output types are Eigen 2D vector.
To debug the issue, I added printf("...%14.6a...")
in this function to print all the in/out values and found:
At commit 1:
# (v1.x(), v1.y(); v2.x(), v2.y()) -> (out.x(), out.y())
( 0x1.02aa4ep+2,-0x1.589246p-9; 0x1.ffffdep-1,0x1.46509cp-10) -> ( 0x1.02aa2ep+2,-0x1.f5ff6ap-8)
At commit 2:
# (v1.x(), v1.y(); v2.x(), v2.y()) -> (out.x(), out.y())
( 0x1.02aa4ep+2,-0x1.589246p-9; 0x1.ffffdep-1,0x1.46509cp-10) -> ( 0x1.02aa30p+2,-0x1.f5ff6ap-8)
The four input floats are bitwise identical, but one of the output is different by the least significant bit. There is not change to this function (inlined, in header file). --fmad
is not specified anywhere in nvcc options.
What might possibly be the underlying issue here? How can code changes else where affects the behavior of this function?
Note that not all call to this function resulted in different result between two commits, another call that was logged had:
( 0x1.e7f416p+2, 0x1.8df0bcp-3; 0x1.ffffd8p-1,-0x1.5ea958p-10) -> ( 0x1.e7efaep+2, 0x1.a2d3b0p-3)
on both commits.