C Specification

To create a kernel object, use the function

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

Parameters

  • program is a program object with a successfully built executable.

  • kernel_name is a function name in the program declared with the __kernel qualifier.

  • errcode_ret will return an appropriate error code. If errcode_ret is NULL, no error code is returned.

Description

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_​KERNEL_​DEFINITION if the function definition for __kernel function given by kernel_name such as the number of arguments, the argument types are not the same for all devices for which the program executable has been built.

  • CL_​INVALID_​VALUE if kernel_name is NULL.

  • CL_​OUT_​OF_​RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.

  • CL_​OUT_​OF_​HOST_​MEMORY if there is a failure to allocate resources required by the OpenCL implementation on the host.

See Also

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.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.