4 Replies Latest reply on Dec 21, 2015 3:39 AM by dipak

    Issue with signed zero handling


      To replicate:

      Compile the following and pass in x = 1.f.  Run on GPU device.

      Expected behaviour: main_float_ returns -Inf.

      Observed behaviour: main_float_ returns +Inf.


      I suspect this is due to a mishandling of signed zero optimsations.

      By default OpenCL shouldn't ignore signed zeros.

      If you do the computation with signed zeros, should get -Inf

      If you ignore signed zeros, then you can optimise

      0.f * (x - 2.f)



      giving +Inf overall.  But this optimisation shouldn't be done if not explicitly requested.





      float main_float_(const float x)


              return (2.f / (0.f * (x - 2.f)));



      __kernel void main_kernel(float x, __global float * const restrict output_buffer)


              output_buffer[0] = main_float_(x);






      AMD Catalyst Control Center Version: 2015.0804.21.41908

      Catalyst Version: 15.7.1

      GPU: HD7770