How to compile the OpenCL core into a bitstream?

How to compile the OpenCL core into a bitstream that I can later download directly without recompiling? My platform is an AMD machine with discrete APU and AMD GPUs. The device runs the latest AMD APP SDK, which supports OpenCL 1.2.

+6
source share
1 answer

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.

+9
source

Source: https://habr.com/ru/post/920085/


All Articles