CL_OUT_OF_RESOURCES - what are the usual usual causes of this error

Hi forum,

I am trying to create the OpenCL 2D Texture from the GL Texture Buffer object as follows:


......................
.......................
	 if( texture_target == GL_TEXTURE_2D || texture_target == GL_TEXTURE_RECTANGLE )
	 {
	    memory._m_clGraphicsArrayBuffer = clCreateFromGLTexture2D(cxt->_m_clContext,
								      CL_MEM_READ_WRITE,
								      texture_target,
								      0,
								      tex->id(),
								      &errNum);
	    
	    if(errNum != CL_SUCCESS)
	    {
	       osg::notify(osg::FATAL) << __FUNCTION__ << ": unable to pull out the 2D OpenCL texture memory from the OpenGL memory: " << cxt->getErrorString(errNum)  << std::endl;
	       
	       return false;
	    }
	 }

I am getting the error notification as mentioned in the code snippet. Any idea of the possible causes of the error - CL_OUT_OF_RESOURCES ?

Thanks
Sajjadul

I am making it more specific . Where to look into if you have this type of error . The specification only says that :

“CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.”

When do we have this type of failure ?

Thanks

Sajjadul

Hi there,

on NVidia hardware this can also be cause by when the device is lost

5.1 (Unavailable devices)

o If a device(s) becomes unavailable after a context and command-queues that use
this device(s) have been created and commands have been queued to them, the
implementation will fail with the CL_OUT_OF_RESOURCES error for further API
calls. The state of the commands enqueued so far is left undefined.

Found in

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\doc

Hi

I am attaching the code snippet where i am getting this error:


	 //get the texture target
	 GLenum texture_target = tex->target();

	 //create buffer based on the texture target
	 if( texture_target == GL_TEXTURE_2D || texture_target == GL_TEXTURE_RECTANGLE )
	 {
	    (memory._m_clGraphicsArrayBuffer) = clCreateFromGLTexture2D(cxt->_m_clContext,
									CL_MEM_READ_WRITE,
									texture_target,
									0,
									tex->id(),
									&errNum);
	    
	    if(errNum != CL_SUCCESS)
	    {
	       osg::notify(osg::FATAL) << __FUNCTION__ << ": " << __LINE__  << ": unable to pull out the 2D OpenCL texture memory from the OpenGL memory: " << cxt->getErrorString(errNum)  << std::endl;
	       
	       return false;
	    }

And disgnostics says that i am out of resource “unable to pull out the 2D OpenCL texture memory from the OpenGL memory: CL_OUT_OF_RESOURCES”

I am also attaching the kernel :


const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_LINEAR;


__kernel void swapKernel(__read_only image2d_t srcArray,
			 __global float4* trgBuffer,
			 __read_only unsigned int pitch)
{
    //get the width and height of the source image array
    int width = get_image_width(srcArray);
    int height = get_image_height(srcArray);

    //compute the thread dimension
    int2 coord = (int2)(get_global_id(0),get_global_id(1));
    
    if(coord.x < width && coord.y < height)
    {
	float offset_X = (1.0f/(float)width) * 0.5f;
	float offset_Y = (1.0f/(float)height) * 0.5f;

	//now compute the texture coordinates
	float2 texCoord = (float2) ( ((float)coord.x/(float)width) + offset_X,
	                             ((float)coord.y/(float)height) + offset_Y );

        //sample value
	float4 src = read_imagef(srcArray,sampler,coord);

	//swap channels and store the color value
	float4 color = (float4)(src.z,src.x,src.y,src.w);
	
	//compute the target address
	float4* target = (float4*)(((char*) trgBuffer ) + pitch *  coord.y ) + coord.x;

        //I GET THE OUT OF RESOURCE IF I AM TRYING TO WRITE 
	(*target) = color;
    }
}

I am trying to write to the buffer and i get the error that i am out of resource.

Any idea folks ?

Thanks
Sajjadul

Are there 2 Graphics Device in Use? Have you created GL an CL on the same device correctly?

I have only one GPU device that i am working with and i have created the context with the opengl opencl interoperability. The context creation did not complain .

Any other thoughts ?

Thanks
Sajjadul