Reads an OpenCL buffer into an array and returns the number of read elements.

uint  CLBufferRead(
   int          buffer,                    // A handle to the OpenCL buffer
   const void&  data[],                    // An array of values
   uint         buffer_offset=0,           // An offset in the OpenCL buffer in bytes, 0 by default
   uint         data_offset=0,             // An offset in the array in elements, 0 by default
   uint         data_count=WHOLE_ARRAY     // The number of values from the buffer for reading, the whole buffer by default



[in]   A handle of the OpenCL buffer.


[in]  An array for receiving values from the OpenCL buffer. Passed by reference.


[in]  An offset in the OpenCL buffer in bytes, from which reading begins. By default, reading start with the very beginning of the buffer.


[in]  The index of the first array element for writing the values of the OpenCL buffer. By default, writing of the read values into an array starts from the zero index.


[in]  The number of values that should be read. The whole OpenCL buffer is read by default.

Return Value

The number of read elements. 0 is returned in case of an error. For information about the error, use the GetLastError() function.


For one-dimensional arrays, the number of the element, into which writing of data into an OpenCL buffer begins, is calculated taking into account the AS_SERIES flags.

An array of two or more dimensions is presented as one-dimensional. In this case, data_offset is the number of elements that should be skipped in the presentation, not the number of elements in the first dimension.