C Specification

To set a device pointer as the argument value for a specific argument of a kernel, call the function

// Provided by cl_ext_buffer_device_address
cl_int clSetKernelArgDevicePointerEXT(
    cl_kernel kernel,
    cl_uint arg_index,
    cl_mem_device_address_ext arg_value);
clSetKernelArgDevicePointerEXT is provided by the cl_ext_buffer_device_address extension.

Parameters

  • kernel is a valid kernel object.

  • arg_index is the argument index. Arguments to the kernel are referred by indices that go from 0 for the leftmost argument to n - 1, where n is the total number of arguments declared by a kernel.

  • arg_value is the device pointer that should be used as the argument value for argument specified by arg_index. The device pointer specified is the value used by all API calls that enqueue kernel (clEnqueueNDRangeKernel and clEnqueueTask) until the argument value is changed by a call to clSetKernelArgDevicePointerEXT for kernel. The device pointer can only be used for arguments that are declared to be a pointer to global memory allocated with clCreateBufferWithProperties with the CL_MEM_DEVICE_PRIVATE_ADDRESS_EXT property. The pointer value specified as the argument value can be the pointer to the beginning of the buffer or any offset into the buffer region. The device pointer value must be naturally aligned according to the argument’s type. It should be noted that it’s legal to pass invalid pointers as the value (similarly to C/C++ function calls with pointer arguments) as long as the kernel doesn’t dereference the pointer.

Description

clSetKernelArgDevicePointerEXT returns CL_SUCCESS if the argument was set successfully. Otherwise, it returns one of the following errors:

  • CL_INVALID_KERNEL if kernel is not a valid kernel object.

  • CL_INVALID_OPERATION if no devices in the context associated with kernel support the cl_ext_buffer_device_address extension.

  • CL_INVALID_ARG_INDEX if arg_index is not a valid argument index.

  • 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 2014-2025 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0