9 Replies Latest reply on Aug 10, 2010 10:14 AM by MicahVillmow

    Strange double precision results

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

        • Strange double precision results
          omkaranathan

          Which device are you running the code on?

          • Strange double precision results
            coggy

            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.

            • Strange double precision results
              genaganna

               

              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.

                • Strange double precision results
                  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.

                    • Strange double precision results
                      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.

                        • Strange double precision results
                          coggy

                           

                          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.

                    • Strange double precision results
                      MicahVillmow
                      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).