Float number with OpenCL in CPU, doesn't appear the decimal part

194 Views Asked by At

I have this code in OpenCL:

__kernel void vector_add(__global float *C) {
    int i = get_global_id(0);
    float t =3.5f;
    C[i] = t;
}

When I run in GPU the return in variable C is 3.5, so it's ok. But when I run in CPU the return is 3.0. This happen with any float value.

But if I run this code:

__kernel void vector_add(__global const float A, __global float *C) {
    int i = get_global_id(0);
    C[i] = A;
}

And I passed the 3.5 value to variable A, this run ok in CPU and GPU.

Why this happen?

0

There are 0 best solutions below