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

# clEnqueueNativeKernel(3clc)

Enqueues a command to execute a native C/C++ function not compiled using the OpenCL compiler.

## NAME

clEnqueueNativeKernel - Enqueues a command to execute a native C/C++ function not compiled using the OpenCL compiler.

##

**cl\_int clEnqueueNativeKernel(cl\_command\_queue** *command\_queue***, void** *(\*user\_func)(void \*)***, void \****args***, size\_t** *cb\_args***, cl\_uint** *num\_mem\_objects***, const cl\_mem \****mem\_list***, const void \****\*args\_mem\_loc***, cl\_uint** *num\_events\_in\_wait\_list***, const cl\_event \****event\_wait\_list***, cl\_event \****event***);**

## PARAMETERS

 *command\_queue*

A valid command-queue. A native user function can only be executed on a command-queue created on a device that has **CL\_EXEC\_NATIVE\_KERNEL** capability set in **CL\_DEVICE\_EXECUTION\_CAPABILITIES** as specified in the table of OpenCL Device Queries for [**clGetDeviceInfo**(3clc)](/clGetDeviceInfo/3clc.md).

 *user\_func*

A pointer to a host-callable user function.

 *args*

A pointer to the args list that *user\_func* should be called with.

 *cb\_args*

The size in bytes of the args list that *args* points to.

The data pointed to by *args* and *cb\_args* bytes in size will be copied and a pointer to this copied region will be passed to *user\_func*. The copy needs to be done because the memory objects (**cl\_mem** values) that *args* may contain need to be modified and replaced by appropriate pointers to global memory. When **clEnqueueNativeKernel** returns, the memory region pointed to by *args* can be reused by the application.

 *num\_mem\_objects*

The number of buffer objects that are passed in *args*.

 *mem\_list*

A list of valid buffer objects, if *num\_mem\_objects* \> 0. The buffer object values specified in *mem\_list* are memory object handles (**cl\_mem** values) returned by [**clCreateBuffer**(3clc)](/clCreateBuffer/3clc.md) or NULL.

 *args\_mem\_loc*

A pointer to appropriate locations that *args* points to where memory object handles (**cl\_mem** values) are stored. Before the user function is executed, the memory object handles are replaced by pointers to global memory.

  *event\_wait\_list*  and   *num\_events\_in\_wait\_list*

Specify events that need to complete before this particular command can be executed. If *event\_wait\_list* is NULL, then this particular command does not wait on any event to complete. If *event\_wait\_list* is NULL, *num\_events\_in\_wait\_list* must be 0. If *event\_wait\_list* is not NULL, the list of events pointed to by *event\_wait\_list* must be valid and *num\_events\_in\_wait\_list* must be greater than 0. The events specified in *event\_wait\_list* act as synchronization points. The context associated with events in *event\_wait\_list* and *command\_queue* must be the same. The memory associated with *event\_wait\_list* can be reused or freed after the function returns.

## NOTES

The total number of read-only images specified as arguments to a kernel cannot exceed **CL\_DEVICE\_MAX\_READ\_IMAGE\_ARGS**. Each 2D image array argument to a kernel declared with the read\_only qualifier counts as one image.

The total number of write-only images specified as arguments to a kernel cannot exceed **CL\_DEVICE\_MAX\_WRITE\_IMAGE\_ARGS**. Each 2D image array argument to a kernel declared with the write-only qualifier counts as one image.

## ERRORS

Returns CL\_SUCCESS if the user function execution instance was successfully queued, or one of the errors below:

• CL\_INVALID\_COMMAND\_QUEUE if *command\_queue* is not a valid command-queue.

• CL\_INVALID\_CONTEXT if context associated with *command\_queue* and events in *event-wait\_list* are not the same.

• CL\_INVALID\_VALUE if *user\_func* is NULL.

• CL\_INVALID\_VALUE if *args* is a NULL value and *cb\_args* \> 0, or if *args* is a NULL value and *num\_mem\_objects* \> 0.

• CL\_INVALID\_VALUE if *args* is not NULL and *cb\_args* is 0.

• CL\_INVALID\_VALUE if *num\_mem\_objects* \>  0 and *mem\_list* or *args\_mem\_loc* are NULL.

• CL\_INVALID\_VALUE if *num\_mem\_objects* = 0 and *mem\_list* or *args\_mem\_loc* are not NULL.

• CL\_INVALID\_OPERATION if the device associated with *command\_queue* cannot execute the native kernel.

• CL\_INVALID\_MEM\_OBJECT if one or more memory objects specified in *mem\_list* are not valid or are not buffer objects.

• CL\_OUT\_OF\_RESOURCES if there is a failure to queue the execution instance of *kernel* on the command-queue because of insufficient resources needed to execute the kernel.

• CL\_MEM\_OBJECT\_ALLOCATION\_FAILURE if there is a failure to allocate memory for data store associated with buffer objects specified as arguments to *kernel*.

• CL\_INVALID\_EVENT\_WAIT\_LIST if *event\_wait\_list* is NULL and *num\_events\_in\_wait\_list* \> 0, or *event\_wait\_list* is not NULL and *num\_events\_in\_wait\_list* is 0, or if event objects in *event\_wait\_list* are not valid events.

• 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

[**clEnqueueNDRangeKernel**(3clc)](/clEnqueueNDRangeKernel/3clc.md), [**clEnqueueNativeKernel**(3clc)](/clEnqueueNativeKernel/3clc.md), [**clCreateCommandQueue**(3clc)](/clCreateCommandQueue/3clc.md), [**clCreateBuffer**(3clc)](/clCreateBuffer/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 174, section 5.8 - Executing Kernels (updated for 1.2 rev 14)
