5.1.2 Runtime setup
You can use the runtime API for many different operations.
The runtime API helps you to:
Create a command queue.
- Compile and build your program objects. Issue commands to compile and
build your source code and extract kernel objects from the compiled code.
You must follow this sequence of commands:
Create the program object by calling either
- creates the program object from the kernel source code.
- creates the program with a pre-compiled binary file.
- Call the
clBuildProgram() function to
compile the program object for the specific devices on the system.
Build a program executable.
Create the kernel and memory objects:
clCreateKernel() function for each kernel, or call the
clCreateKernelsInProgram() function to create kernel
objects for all the kernels in the OpenCL application.
- Use the OpenCL API to allocate memory buffers. You can use the
to enable the application processor to access the data.
Enqueue and execute the kernels.
Enqueue to the command queues the commands that control the sequence and
synchronization of kernel execution, mapping and unmapping of memory, and manipulation of
To execute a kernel function, you must do the following steps:
clSetKernelArg() for each parameter in the kernel function definition to
set the kernel parameter values.
- Determine the work-group size and the index space to use to execute
- Enqueue the kernel for execution in the command queue.
Enqueue commands that make the results from the work-items available to
Clean up the unused objects.