Hi All,
I found that the result of cos(1611.625) is incorrect. It's 1.0 on GPU, whereas it's -0.9893 on CPU.
My box is HD4870, AMD Stream SDK 1.3 and Ubuntu amd64.
Is it a bug?
Thanks
Traits
Try sending 1611.625 as a constant parameter to kernel so that its value is not determined at compile time. It will help us know if its an issue with compiler or hadware floating point accuracy.
The test code:
kernel void cosin_testcase(float x<>, out float y<>)
{
y=cos(x);
}
int main()
{
int length=4;
float * x, *y;
int i=0;
x=(float*) malloc(sizeof(float) *length);
y=(float*) malloc(sizeof(float) *length);
for(i=0;i<length;i++){
x [ i ]=1611.625f;
y [ i ]=0.0f;
}
{
float x_stream<length>;
float y_stream<length>;
x_stream.read(x);
cosin_testcase(x_stream, y_stream);
y_stream.write(y);
}
for(i=0;i<length;i++){
printf("%lf\n",y [ i ] );
}
free(x);
free(y);
return 0;
}
hmmm.....seems an issue with floating point accuracy.
Try 1611.625 - 256 * 2 *PI = 2.482f and see if it works.
Originally posted by: gaurav.garg hmmm.....seems an issue with floating point accuracy.
Try 1611.625 - 256 * 2 *PI = 2.482f and see if it works.
I try 1611.625 - 256 * 2 *PI =3.12956f. The result is correct (-0.999928).
Hardware implementation of sin/cos requires input value to be within -100*PI to 100*PI.