O'Reilly logo

OpenCL Programming by Example by Koushik Bhattacharyya, Ravishekhar Banger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required