Reading and writing buffers
By now you know how to create buffer objects and how to read them in the kernel. Before the kernel is launched you may want to write the buffer to the device memory using the API clEnqueueWriteBuffer
. And after the kernel has completed processing, you will want to get the buffer back to the host from the device memory. This can be achieved by using the clEnqueueReadBuffer
function.
cl_int clEnqueueWriteBuffer (cl_command_queue command_queue,cl_mem buffer,cl_bool blocking_write,size_t offset,size_t size,const void *ptr,cl_uint num_events_in_wait_list,const cl_event *event_wait_list,cl_event *event)
This function writes data from the host to the device memory. Following are the descriptions of the parameters passed.
Parameter ... |
---|
Get OpenCL Programming by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.