title: Why do I get a CL_MEM_OBJECT_ALLOCATION_FAILURE?
body: <p>I'm allocating a cl_mem buffer on a <a href="http://en.wikipedia.org/wiki/Graphics_processing_unit" rel="nofollow noreferrer">GPU</a> and work on it, which works fine until a certain size is exceeded. In that case the allocation itself succeeds, but execution or copying does not. I do want to use the device's memory for faster operation so I allocate like:</p>
  
  <pre><code>buf = clCreateBuffer (cxGPUContext, CL_MEM_WRITE_ONLY, buf_size, NULL, &amp;ciErrNum);
  </code></pre>
  
  <p>Now what I don't understand is the size limit. I'm copying about 16 Mbyte but should be able to use about 128 Mbyte (see <code>CL_DEVICE_MAX_MEM_ALLOC_SIZE</code> ).</p>
  
  <p><em>Why do these numbers differ so much ?</em></p>
  
  <hr>
  
  <p>Here's some excerpt from oclDeviceQuery:</p>
  
  <pre><code> CL_PLATFORM_NAME:  NVIDIA
   CL_PLATFORM_VERSION:  OpenCL 1.0 
   OpenCL SDK Version:  4788711
  
    CL_DEVICE_NAME:          GeForce 8600 GTS
    CL_DEVICE_TYPE:          CL_DEVICE_TYPE_GPU
    CL_DEVICE_ADDRESS_BITS:              32
    CL_DEVICE_MAX_MEM_ALLOC_SIZE:  128 MByte
    CL_DEVICE_GLOBAL_MEM_SIZE:     255 MByte
    CL_DEVICE_LOCAL_MEM_TYPE:      local
    CL_DEVICE_LOCAL_MEM_SIZE:      16 KByte
    CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:  64 KByte
  </code></pre>