Strange double precision results

Discussion created by douglas125 on Jun 6, 2010
Latest reply on Aug 10, 2010 by MicahVillmow
Strange cl_khr_fp64 double results when using double constants

Hi. I'm attempting to use the cl_khr_fp64 extension for double precision math but I get VERY strange results.

I can't use floating point double constants. As shown in the code below, the kernel with 0.6666666667 doesn't work and the kernel with 2/3 works. When I input x[0] = 0.005 the wrong answer is a ridiculous 5.972665E+100 while the correct answer is, well, correct.

Strangely enough, wrong results only appear when I try to multiply the double constant by a double in global memory. Any clues?

#pragma OPENCL EXTENSION cl_khr_fp64 : enable __kernel void doubledydxNOTWORKING(__global double * x, __global double * y, __global double * dydx) { dydx[0] = 0.666666666666667 * x[0]; } __kernel void doubledydxWORKS(__global double * x, __global double * y, __global double * dydx) { dydx[0] = x[0]*2/3; }