C Specification
To create kernel objects for all kernel functions in a program, call the function
// Provided by CL_VERSION_1_0
cl_int clCreateKernelsInProgram(
cl_program program,
cl_uint num_kernels,
cl_kernel* kernels,
cl_uint* num_kernels_ret);
Parameters
-
program is a program object with a successfully built executable.
-
num_kernels is the size of memory pointed to by kernels specified as the number of
cl_kernelentries. -
kernels is the buffer where the kernel objects for kernels in program will be returned. If kernels is
NULL, it is ignored. If kernels is notNULL, num_kernels must be greater than or equal to the number of kernels in program. -
num_kernels_ret is the number of kernels in program. If num_kernels_ret is
NULL, it is ignored.
Description
Kernel objects are not created for any __kernel functions in program
that do not have the same function definition across all devices for which a
program executable has been successfully built.
Kernel objects can only be created once you have a program object with a
valid program source or binary loaded into the program object and the
program executable has been successfully built for one or more devices
associated with program.
No changes to the program executable are allowed while there are kernel
objects associated with a program object.
This means that calls to clBuildProgram and clCompileProgram return
CL_INVALID_ if there are kernel objects attached to a program
object.
The OpenCL context associated with program will be the context associated
with kernel.
The list of devices associated with program are the devices associated
with kernel.
Devices associated with a program object for which a valid program
executable has been built can be used to execute kernels declared in the
program object.
clCreateKernelsInProgram will return CL_SUCCESS if the kernel objects were
successfully allocated.
Otherwise, it returns one of the following errors:
-
CL_INVALID_if program is not a valid program object.PROGRAM -
CL_INVALID_if there is no successfully built executable for any device in program.PROGRAM_ EXECUTABLE -
CL_INVALID_if kernels is notVALUE NULLand num_kernels is less than the number of kernels in program. -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the device.OF_ RESOURCES -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the host.OF_ HOST_ MEMORY
Document Notes
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.