In this section we will discuss details about the kernel objects, and how kernel objects can be created using the program objects. Every program is a collection of kernels, you can consider a program object as a library of kernels. As shown in the following figure a program
is associated with kernel1
and kernel2
. The program
is built with inputs as two devices device1
and device2
. A kernel when enqueued on the command queue, the OpenCL runtime generates the binary for execution on the device. Note that each kernel can be executed on different devices. It is at the runtime the binaries are generated.
A kernel object can be created from a well formed OpenCL C program, which is built as discussed in the previous section. A kernel object is an encapsulation for a parallel executable entity. The kernel object is used to pass arguments using the clSetKernelArg
API, before running the kernel using the clEnqueueNDRangeKernel
API. Have a look at the following diagram: