---
name: "clCreateKernel"
section: "3clc"
platform: "linux"
package: "opencl-1.2-man-doc"
version: "1.0~svn33624-5.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/clCreateKernel"
---

# clCreateKernel(3clc)

Creates a kernel object.

## NAME

clCreateKernel - Creates a kernel object.

##

**cl\_kernel clCreateKernel(cl\_program** *program***, const char \****kernel\_name***, cl\_int \****errcode\_ret***);**

## PARAMETERS

 *program*

A program object with a successfully built executable.

 *kernel\_name*

A function name in the program declared with the **\_\_kernel** qualifier

 *errcode\_ret*

Returns an appropriate error code. If *errcode\_ret* is NULL, no error code is returned.

## NOTES

A kernel is a function declared in a program. A kernel is identified by the [**functionQualifiers**(3clc)](/functionQualifiers/3clc.md) 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.

## ERRORS

**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.

## SPECIFICATION

**OpenCL Specification**\[1\]

## SEE ALSO

[**clCreateKernelsInProgram**(3clc)](/clCreateKernelsInProgram/3clc.md), [**clRetainKernel**(3clc)](/clRetainKernel/3clc.md), [**clReleaseKernel**(3clc)](/clReleaseKernel/3clc.md), [**clSetKernelArg**(3clc)](/clSetKernelArg/3clc.md), [**clGetKernelInfo**(3clc)](/clGetKernelInfo/3clc.md), [**clGetKernelWorkGroupInfo**(3clc)](/clGetKernelWorkGroupInfo/3clc.md), [**classDiagram**(3clc)](/classDiagram/3clc.md)

## AUTHORS

**The Khronos Group**

## COPYRIGHT

Copyright © 2007-2011 The Khronos Group Inc.\
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.

## NOTES

- 1\.

  OpenCL Specification

  page 157, section 5.7.1 - Creating Kernel Objects
