Cheeku
Cheeku

Reputation: 873

clEnqueueNDRangeKernel' failed with error 'out of resources'

From my kernel, I call a function say f which has an infinite loop which breaks on ++depth > 5. This works without the following snippet.

for(int j = 0;j < 9;j++){
                    f1 = inside(prev.o, s[j]);
                    f2 = inside(x.o, s[j]);
                    if((f1 ^ f2)){
                        stage = 0;
                        break;
                    }
                    else if(fabs(offset(x.o, s[j])) < EPSILON)
                    {
                        id = j;
                        stage = 1;
                        break;
                    }
            }

Looping over the 9 elements in s is the only thing I do here. This is inside the infinite loop. I checked and this does not have a problem running 2 times but the third time it runs out of memory. What is going on? It's not like I am creating any new variables anywhere. There is a lot of code in the while loop which does more complicated computation than the above snippet and that does not run into a problem. My guess is that I'm doing something wrong with storing s.

Upvotes: 1

Views: 3123

Answers (1)

DarkZeros
DarkZeros

Reputation: 8410

If you read the OpenCL documentation, the error is not produced because the kernel code is wrong. The code is not even run at all, it all happens at the queueing step:

OpenCL: clEnqueuNDRangeKernel

CL_OUT_OF_RESOURCES: If there is a failure to queue the execution instance of kernel on the command-queue because of insufficient resources needed to execute the kernel. For example, the explicitly specified local_work_size causes a failure to execute the kernel because of insufficient resources such as registers or local memory. Another example would be the number of read-only image args used in kernel exceed the CL_DEVICE_MAX_READ_IMAGE_ARGS value for device or the number of write-only image args used in kernel exceed the CL_DEVICE_MAX_WRITE_IMAGE_ARGS value for device or the number of samplers used in kernel exceed CL_DEVICE_MAX_SAMPLERS for device.

Check the local memory size, local group size, constant memory and kernel arguments size.

Upvotes: 4

Related Questions