I’m having a strange and frustrating problem.
The following code in OpenCL (running on GPU Intel 5500)
int col = get_global_id(0);
float cx;
cx = ((float)col)/((float)2.0f);
return zero.
if I substitute the last line with this one:
cx = ((float)col)*0.5f);
everything works fine.
Any division I tried keeps returning zero. Multiplications work just fine …
Am I missing something? Is there a setting I missed or some what to figure out if there’s an error that I am not seeing?
I’ve been banging my head against this for the whole night. I searched but I didn’t find anyone else that is experiencing this problem (let alone find a hint of a solution).
Everything compiles fine and I don’t see any runtime errors. Here’s some system stats (in case it helps):
Using platform:
Intel® OpenCL.
Using device:
Intel® HD Graphics 5500.
With Max Compute Units: 24
With Max WG sizes: 256
With Max WI sizes: 256
With Max num sub groups: 256
With Max WI dimensions: 3
This is the full kernel code just in case:
void kernel mainCL(global const uint* dimbuf, global const float* inBuf, global float* outBuf) {
int row = get_global_id(1);
int col = get_global_id(0);
int grow = get_group_id(1);
int gcol = get_group_id(0);
uint width = dimbuf[0];
uint height = dimbuf[1];
float cx; float cy;
cx = ((float)col)/2.0f;
cy = ((float)row)/2.0f;
outBuf[row*width + col] =cx + cy;
}
The code above does not work. it produces a matrix of all zeros.
again, if I replace the 2 lines of assignment to cx and cy with the following:
cx = ((float)col)*0.5f;
cy = ((float)row)*0.5f;
it works just fine and returns what I would expect to the host
It’s not that I am getting the wrong number as a result of a division. I am getting zero as a result of any division (I tried dividing by numbers other than 2.0f and it still returns a matrix of zeros).
That’s just the kernel code by the way … if you want I can post the host code (it’s just a bit long … which is why I didn’t post it) but I don’t think that’s the problem since as long as I don’t perform any divisions inside the kernel, I get the results I expect.
Thanks!