clWaitForEvents returns CL_OUT_OF_RESOURCES

Hello,

after staring a quite big kernel on multiple devices. I call the clWaitForEvents function to synchronize the devices after they finished their execution.
But clWaitForEvents returns with a CL_OUT_OF_RESOURCES error.

The OpenCL Specification says that clWaitForEvents return CL_SUCCESS, CL_INVALID_VALUE, CL_INVALID_CONTEXT or CL_INVALID_EVENT, but not CL_OUT_OF_RESOURCES.

So why does it return this error and what could be the reason for that ?

Thanks

It seems the OpenCL 1.1 specs have changed that, now clWaitForEvents() may return CL_OUT_OF_RESOURCES “if there is a failure to allocate resources required by the OpenCL implementation on the device”, see [1].

I’m also seeing clWaitForEvents() return CL_OUT_OF_RESOURCES in a case where I run the same kernel (with different arguments) twice to calculate different output buffers. I’d understand this if I tried to run the kernels asynchronously, but I’m explicitly waiting for them to finish. The code basically looks like

for (size_t i=0;i<outputs.size();++i) {

    s_kernel->setArg(0,*outputs[i]);

cl::KernelFunctor func=s_kernel->bind(*s_queue,cl::NDRange(0,0,offset_z),global,g_local);

    if (i==0) {

        result=func(upload).wait();

    }

    else {

        result=func().wait(); // This returns -5==CL_OUT_OF_RESOURCES.

    }

    if (result!=CL_SUCCESS) {

        fprintf(stderr,"Error: Unable to run the kernel (code %d).",result);

        return false;

    }

offset_z+=offset_z_step;

}

The first loop iteration works fine, but in the second one I’m getting CL_OUT_OF_RESOURCES. Any hints why?

[1] http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html

It seems the OpenCL 1.1 specs have changed that, now clWaitForEvents() may return CL_OUT_OF_RESOURCES “if there is a failure to allocate resources required by the OpenCL implementation on the device”, see [1].

I’m also seeing clWaitForEvents() return CL_OUT_OF_RESOURCES in a case where I run the same kernel (with different arguments) twice to calculate different output buffers. I’d understand this if I tried to run the kernels asynchronously, but I’m explicitly waiting for them to finish. The code basically looks like

for (size_t i=0;i<outputs.size();++i) {

    s_kernel->setArg(0,*outputs[i]);

cl::KernelFunctor func=s_kernel->bind(*s_queue,cl::NDRange(0,0,offset_z),global,g_local);

    if (i==0) {

        result=func(upload).wait();

    }

    else {

        result=func().wait(); // This returns -5==CL_OUT_OF_RESOURCES.

    }

    if (result!=CL_SUCCESS) {

        fprintf(stderr,"Error: Unable to run the kernel (code %d).",result);

        return false;

    }

offset_z+=offset_z_step;

}

The first loop iteration works fine, but in the second one I’m getting CL_OUT_OF_RESOURCES. Any hints why?

[1] http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clWaitForEvents.html

CL_OUT_OF_RESOURCES seems to be a catch-all error code for “something went wrong”. For me it usually means my OpenCL kernel has attempted an illegal memory access somewhere.

CL_OUT_OF_RESOURCES seems to be a catch-all error code for “something went wrong”. For me it usually means my OpenCL kernel has attempted an illegal memory access somewhere.

Yes, it seems so, thanks for your reply. Meanwhile, I have worked around the issue by writing another kernel which takes two outputs, instead of running the kernel with one output twice.

Yes, it seems so, thanks for your reply. Meanwhile, I have worked around the issue by writing another kernel which takes two outputs, instead of running the kernel with one output twice.

hey , It happened to me in this case , when i tried to do illegal memory access .
So , i passed float4 data from host side and happened to keep the buffer’s datatype in kernel as double.
So , might be error inside the code (either host or device side )

And I also encountered it , when my memory requirement exceeded device memory . Like , I needed 1024 bytes mem , when i had a device that has a maximum buffer capacity of 512 etc .