3

I found a problem with floating point arithmetic in OpenCL. This is my kernel:

__kernel void MyKernel(__global const float4* _pInput, __global float4* _pOutput)
{
    int IndexOfRow      = get_global_id(0);
    int NumberOfRows    = get_global_size(0);
    int IndexOfColumn   = get_global_id(1);
    int NumberOfColumns = get_global_size(1);

    ...

   _pOutput[0] = 1.9f * 100.0f; // constant float return value
}

After the kernel execution and download of the output buffer the result is always 100 on different clients using an ssh connection. If I execute the program locally the result is 190. It seems that the digits after the decimal point are cut off.

The operating system is a Open Suse Linux with AMD OpenCL 1.2.

What's the problem?

1
  • If you make index different for each thread, it will be 190.0 or 189.999. You have made it zero and that can be undefined behaviour while all threads race for a single element. Commented Dec 11, 2013 at 10:46

1 Answer 1

4

I just found the solution. It depends on your ENV setting for LANG. It has to be en_US.UTF-8. You can check it with env|grep LANG.

That’s probably a JIT compiler bug. In Germany floating points are written with an „,“ instead of „.“.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.