1) compile the kernel into the program from the source using the clCreateProgamWithSource API call. Compiler errors are retrieved when the clGetProgramBuildInfo API is called.
2) use the clGetProgramInfo API call to get CL_PROGRAM_BINARY_SIZES. These are the sizes of the software binaries. 2a) Allocate memory for binary files using sizes from 2)
3) use the clGetProgramInfo API call to get CL_PROGRAM_BINARIES. This gets the binary code of the program.
4) The binary file can be converted to an OpenCL program object with a call to the clCreateProgamWithBinary API.
It combines a specific device, so a binary file compiled on a specific device will not run on another device.
For one process instance, when you have an environment (platform, device, context, and queue), you can simply reuse the OpenCL Kernel object and re-execute it with another clEnqueueNDRange API call.
source share