5.5 Creating OpenCL program objects

Create an OpenCL program object.

The OpenCL program object encapsulates the following components:

The program object is loaded with the kernel source code, then the code is compiled for the devices attached to the context. All kernel functions must be identified in the application source with the __kernel qualifier. OpenCL applications can also include functions that you can call from your kernel functions.

Load the OpenCL C kernel source and create an OpenCL program object from it.

To create a program object, use the clCreateProgramWithSource() function. For example:

//        Create OpenCL program

program = clCreateProgramWithSource(context, device, “<kernel source>”);
if (program == NULL)
       return 1;

There are different options for building OpenCL programs:

Creating a program object from a binary is a similar process to creating a program object from source code, except that you must supply the binary for each device that you want to execute the kernel on. Use the clCreateProgramWithBinary() function to do this.

Use the clGetProgramInfo() function to obtain the binary after you have generated it.

Non-ConfidentialPDF file icon PDF version101574_0302_00_en
Copyright © 2019 Arm Limited or its affiliates. All rights reserved.