Creates a kernal object.

cl_kernel clCreateKernel ( cl_program  program,
  const char *kernel_name,
  cl_int *errcode_ret)



A program object with a successfully built executable.


A function name in the program declared with the __kernel qualifier




A kernel is a function declared in a program. A kernel is identified by the __kernel qualifier applied to any function in a program. A kernel object encapsulates the specific __kernel function declared in a program and the argument values to be used when executing this __kernel function.


clCreateKernel returns a valid non-zero kernel object and errcode_ret is set to CL_SUCCESS if the kernel object is created successfully. Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:

  • CL_INVALID_PROGRAM if program is not a valid program object.
  • CL_INVALID_PROGRAM_EXECUTABLE if there is no successfully built executable for program.
  • CL_INVALID_KERNEL_NAME if kernel_name is not found in program.
  • CL_INVALID_VALUE if kernel_name is NULL.


OpenCL Specification

Also see

clCreateKernelsInProgram, clRetainKernel, clReleaseKernel, clSetKernelArg, clGetKernelInfo, clGetKernelWorkGroupInfo, Cardinality Diagram
