cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

lava555
Journeyman III

problem when add two float variable in GPU

When i run a demo, the two results on GPU and CPU of two variables is not

the same, and the precision of result is very low on GPU. for example:

float var1 =  0.89652568101882935000;

float var2 =  1.02036583423614500000;

And the results are as follows:

CPU: 1.02036587893962861000

GPU: 1.02036583423614500000

Obviously the result of GPU is not right of my  expectation. 

Ps: I added a predefine as that:

#pragma OPENCL EXTENSION cl_khr_fp64 : enable 

for the need of handling my data set. But i think it should not has any effect on adding two float data.

So what have happened on GPU? Can i avoid this precision problem?

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

0 Likes
2 Replies
Curiouscat
Journeyman III

You're using floats, i.e. single precision, so you should expect roughly 7 significant digits (in decimal). And that's what you're getting.

0 Likes

thanks Curious cat ~

0 Likes