C Specification
To record a command to execute a kernel on a device, call the function
// Provided by cl_khr_command_buffer
cl_int clCommandNDRangeKernelKHR(
cl_command_buffer_khr command_buffer,
cl_command_queue command_queue,
const cl_command_properties_khr* properties,
cl_kernel kernel,
cl_uint work_dim,
const size_t* global_work_offset,
const size_t* global_work_size,
const size_t* local_work_size,
cl_uint num_sync_points_in_wait_list,
const cl_sync_point_khr* sync_point_wait_list,
cl_sync_point_khr* sync_point,
cl_mutable_command_khr* mutable_handle);
clCommandNDRangeKernelKHR is provided by the cl_khr_command_buffer extension.
|
Parameters
-
command_buffer refers to a valid command-buffer object.
-
command_queue specifies the command-queue the command will be recorded to.
If thecl_khr_extension is not supported, only a single command-queue is supported, and command_queue must becommand_ buffer_ multi_ device NULL.
If thecl_khr_extension is supported and command_queue iscommand_ buffer_ multi_ device NULL, then only one command-queue must have been set on command_buffer creation; otherwise, command_queue must not beNULL. -
properties specifies a list of properties for the kernel command and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. If a supported property and its value is not specified in properties, its default value will be used. properties may be
NULL, in which case the default values for supported properties will be used. Thecl_khr_extension does not define any properties, but supported properties defined by extensions are defined in the List of supported properties by clCommandNDRangeKernelKHR table.command_ buffer -
kernel is a valid kernel object which must have its arguments set. Any changes to kernel after calling clCommandNDRangeKernelKHR, such as with clSetKernelArg or clSetKernelExecInfo, have no effect on the recorded command. If kernel is recorded to a following clCommandNDRangeKernelKHR command however, then that command will capture the updated state of kernel.
-
work_dim, global_work_offset, global_work_size, local_work_size Refer to clEnqueueNDRangeKernel.
-
sync_point_wait_list, num_sync_points_in_wait_list specify synchronization-points that need to complete before this particular command can be executed.
If sync_point_wait_list is
NULL, num_sync_points_in_wait_list must be 0. If sync_point_wait_list is notNULL, the list of synchronization-points pointed to by sync_point_wait_list must be valid and num_sync_points_in_wait_list must be greater than 0. The synchronization-points specified in sync_point_wait_list are device-side synchronization-points. The command-buffer associated with synchronization-points in sync_point_wait_list must be the same as command_buffer. The memory associated with sync_point_wait_list can be reused or freed after the function returns. -
sync_point returns a synchronization-point ID that identifies this particular command. Synchronization-point objects are unique and can be used to identify this command later on. sync_point can be
NULLin which case it will not be possible for the application to record a wait for this command to complete. If the sync_point_wait_list and the sync_point arguments are notNULL, the sync_point argument should not refer to an element of the sync_point_wait_list array. -
mutable_handle returns a handle to the command. If the
cl_khr_extension is supported, and mutable_handle is notcommand_ buffer_ mutable_ dispatch NULL, it can be used in thecl_mutable_struct to update the command configuration between recordings. The lifetime of this handle is tied to the parent command-buffer, such that freeing the command-buffer will also free this handle.dispatch_ config_ khr
Description
| Recording Properties | Property Value | Description |
|---|---|---|
provided by the |
|
This is a bitfield and can be set to a combination of the following values: An assertion by the user that the number of work-groups of this ND-range kernel will not be updated beyond the number defined when the ND-range kernel was recorded. The number of work-groups is defined as the product for each i from 0 to work_dim - 1 of ceil(global_work_size[i]/local_work_size[i]). |
provided by the |
|
This is a bitfield and can be set to a combination of the following values: If |
|
The work-group size to be used for kernel can also be specified in the
program source using the
These work-group instances are executed in parallel across multiple compute units or concurrently on the same compute unit. Each work-item is uniquely identified by a global identifier. The global ID, which can be read inside the kernel, is computed using the value given by global_work_size and global_work_offset. In addition, a work-item is also identified within a work-group by a unique local ID. The local ID, which can also be read by the kernel, is computed using the value given by local_work_size. The starting local ID is always (0, 0, … 0). |
clCommandNDRangeKernelKHR returns CL_SUCCESS if the function is executed
successfully.
Otherwise, it returns the errors defined by clEnqueueNDRangeKernel except:
CL_INVALID_ is replaced with:
-
CL_INVALID_if theCOMMAND_ QUEUE cl_khr_extension is not supported and command_queue is notcommand_ buffer_ multi_ device NULL. -
CL_INVALID_if theCOMMAND_ QUEUE cl_khr_extension is supported; and either command_queue iscommand_ buffer_ multi_ device NULLand command_buffer was created with more than one queue, or command_queue is notNULLand not a command-queue listed on command_buffer creation.
CL_INVALID_ is replaced with:
-
CL_INVALID_if the context associated with command_buffer and kernel is not the same.CONTEXT -
CL_INVALID_if command_queue is notCONTEXT NULL, and the context associated with command_queue and command_buffer is not the same.
CL_INVALID_ is replaced with:
-
CL_INVALID_if sync_point_wait_list isSYNC_ POINT_ WAIT_ LIST_ KHR NULLand num_sync_points_in_wait_list is > 0, or sync_point_wait_list is notNULLand num_sync_points_in_wait_list is 0, or if synchronization-point objects in sync_point_wait_list are not valid synchronization-points.
New errors:
-
CL_INVALID_if command_buffer is not a valid command-buffer.COMMAND_ BUFFER_ KHR -
CL_INVALID_if command_buffer has been finalized.OPERATION -
CL_INVALID_if values specified in properties are not valid.VALUE -
CL_INVALID_if theVALUE cl_khr_extension is not supported and mutable_handle is notcommand_ buffer_ mutable_ dispatch NULL. -
CL_INVALID_if the device associated with command_queue does not supportOPERATION CL_COMMAND_and kernel contains a printf call.BUFFER_ CAPABILITY_ KERNEL_ PRINTF_ KHR -
CL_INVALID_if the device associated with command_queue does not supportOPERATION CL_COMMAND_and kernel contains a kernel-enqueue call.BUFFER_ CAPABILITY_ DEVICE_ SIDE_ ENQUEUE_ KHR
If the cl_khr_ extension is supported:
-
CL_INVALID_if the requestedOPERATION CL_MUTABLE_properties are not reported byDISPATCH_ UPDATABLE_ FIELDS_ KHR CL_DEVICE_for the device associated with command_queue. If command_queue isMUTABLE_ DISPATCH_ CAPABILITIES_ KHR NULL, the device associated with command_buffer must report support for these properties. -
CL_INVALID_if command_buffer was created with theVALUE CL_COMMAND_property withBUFFER_ MUTABLE_ DISPATCH_ ASSERTS_ KHR CL_MUTABLE_and local_work_size isDISPATCH_ ASSERT_ NO_ ADDITIONAL_ WORK_ GROUPS_ KHR NULL, or if properties includes theCL_MUTABLE_property withDISPATCH_ ASSERTS_ KHR CL_MUTABLE_and local_work_size isDISPATCH_ ASSERT_ NO_ ADDITIONAL_ WORK_ GROUPS_ KHR NULL.
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.