Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
It’s crucial to know how to code and enqueue kernels, but kernels are useless without data to process. The goal of this chapter has been to show how OpenCL packages and partitions data to be processed by devices.
OpenCL provides a memory object (cl_mem) data structure as a standard mechanism for transferring data between a host and a device. The process of transferring memory objects is simple: create a memory object from existing data, and call clSetKernelArg to make the object into a kernel argument. When the kernel executes, the kernel will be able to access its data as a regular function parameter. Then, as the host sends further commands, the device may transfer data to the host or copy the data to another buffer object.