---
name: "clCreateKernelsInProgram"
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/clCreateKernelsInProgram"
---

# clCreateKernelsInProgram(3clc)

Creates kernel objects for all kernel functions in a program object.

## NAME

clCreateKernelsInProgram - Creates kernel objects for all kernel functions in a program object.

##

**cl\_int clCreateKernelsInProgram(cl\_program** *program***, cl\_uint** *num\_kernels***, cl\_kernel \****kernels***, cl\_uint \****num\_kernels\_ret***);**

## PARAMETERS

 *program*

A program object with a successfully built executable.

 *num\_kernels*

The size of memory pointed to by *kernels* specified as the number of **cl\_kernel** entries.

 *kernels*

The buffer where the kernel objects for kernels in *program* will be returned. If *kernels* is NULL, it is ignored. If *kernels* is not NULL, *num\_kernels* must be greater than or equal to the number of kernels in *program*.

 *num\_kernels\_ret*

The number of kernels in *program*. If *num\_kernels\_ret* is NULL, it is ignored.

## NOTES

Creates kernel objects for all kernel functions in *program*. Kernel objects are not created for any [**functionQualifiers**(3clc)](/functionQualifiers/3clc.md) 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**(3clc)](/clBuildProgram/3clc.md) and [**clCompileProgram**(3clc)](/clCompileProgram/3clc.md) return **CL\_INVALID\_OPERATION** 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.

## ERRORS

Returns CL\_SUCCESS if the kernel objects are successfully allocated. Otherwise, it returns one of the following errors:

• CL\_INVALID\_PROGRAM if *program* is not a valid program object.

• CL\_INVALID\_PROGRAM\_EXECUTABLE if there is no successfully built executable for any device in *program*.

• CL\_INVALID\_VALUE if *kernels* is not NULL and *num\_kernels* is less than the number of kernels in *program*.

• 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

[**clCreateKernel**(3clc)](/clCreateKernel/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 158, section 5.7.1 - Creating Kernel Objects
