cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

douglas125
Adept I

Strange double precision results

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; }

0 Likes
9 Replies
omkaranathan
Adept I

Which device are you running the code on?

0 Likes

Sorry for taking long to reply.

I'm using Catalyst 10.5, Win7 64bits running OpenCL on a HD4890 Card.

0 Likes

there is absolutly no support for doubles on 4xxx card under OpenCL. doubles work only o CPU or 58xx or 5970

0 Likes
coggy
Journeyman III

Because I am facing the same problem multiplying doubles, I just tried the code on a Radeon HD 5870 with similar results.

On the GPU: 1.0 * 0.666666666666667 = 1.19453e+103

On the CPU: 1.0 * 0.666666666666667 = 0.6666666667

Using "2/3", the correct result is returned. Any ideas what the reason for this might be, or how to work around the problem? If more information is needed, I'm happy to assist.

0 Likes
genaganna
Journeyman III

Originally posted by: douglas125 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?

 

Extenstion is cl_amd_fp64 for AMD openCL.  It looks like your buildProgram failed.   It should work both on 7xx and 8xx cards.

0 Likes

I tried both using cl_khr_fp64 and cl_amd_fp64 with the same results. Building the program returns 0 and throws no exceptions.

The result of the multiplication for two given doubles, though wrong, is consistent over multiple runs on the GPU.

0 Likes

Originally posted by: coggy I tried both using cl_khr_fp64 and cl_amd_fp64 with the same results. Building the program returns 0 and throws no exceptions.

 

The result of the multiplication for two given doubles, though wrong, is consistent over multiple runs on the GPU.

 

I was not able to reproduce this issue with internal builds.  Fix will be available in future releases.  Thanks for reporting this issue.

0 Likes

Originally posted by: genaganna
Originally posted by: coggy I tried both using cl_khr_fp64 and cl_amd_fp64 with the same results. Building the program returns 0 and throws no exceptions.

 

 

 

The result of the multiplication for two given doubles, though wrong, is consistent over multiple runs on the GPU.

 

 

 

 

I was not able to reproduce this issue with internal builds.  Fix will be available in future releases.  Thanks for reporting this issue.

 

Thanks for your answer. If any more information is needed to reproduce the issue, I'm happy to help.

0 Likes

coggy,
Doubles are not fully supported in 2.1 SDK, the 2.2 SDK has a lot better double support(although some math functions might still be missing).
0 Likes