Writes into the OpenCL buffer and returns the number of written elements.

uint  CLBufferWrite(
   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 array for writing, the whole array by default



[in]  A handle of the OpenCL buffer.


[in]  An array of values that should be written in the OpenCL buffer. Passed by reference.


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


[in]  The index of the first array element, starting from which values from the array are written in the OpenCL buffer. By default, values from the very beginning of the array are taken.


[in]  The number of values that should be written. All the values of the array, by default.

Return Value

The number of written 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, with which reading of data for writing 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.