C Specification
To create a command-buffer that can record commands to the specified queues, call the function
// Provided by cl_khr_command_buffer
cl_command_buffer_khr clCreateCommandBufferKHR(
cl_uint num_queues,
const cl_command_queue* queues,
const cl_command_buffer_properties_khr* properties,
cl_int* errcode_ret);
clCreateCommandBufferKHR is provided by the cl_khr_command_buffer extension.
|
Parameters
-
num_queues is the number of command-queues listed in queues. If the
cl_khr_extension is not supported, this must be one.command_ buffer_ multi_ device -
queues is a pointer to a list of command-queues that the command-buffer commands will be recorded to. queues must be a non-
NULLvalue and the length of the list equal to num_queues. -
properties specifies a list of properties for the command-buffer and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. The list of supported properties is described in the table below. If a supported property and its value is not specified in properties, its default value will be used. properties can be
NULLin which case the default values for supported command-buffer properties will be used.Table 1. clCreateCommandBufferKHR properties Recording Properties Property Value Description == Description CL_COMMAND_BUFFER_ FLAGS_ KHR provided by the
cl_khr_command_bufferextension.cl_command_buffer_ flags_ khr This is a bitfield and can be set to a combination of the following values:
CL_COMMAND_- Allow multiple instances of the command-buffer to be submitted to the device for execution. If set, devices must supportBUFFER_ SIMULTANEOUS_ USE_ KHR CL_COMMAND_.BUFFER_ CAPABILITY_ SIMULTANEOUS_ USE_ KHR provided by the
cl_khr_command_bufferextension.CL_COMMAND_- All commands in the command-buffer must use native synchronization, as reported byBUFFER_ DEVICE_ SIDE_ SYNC_ KHR CL_DEVICE_. This can be used as a safeguard for performant applications that do not want to accidentally fallback to host synchronization when passing multiple queues.COMMAND_ BUFFER_ SYNC_ DEVICES_ KHR provided by the
cl_khr_command_buffer_multi_deviceextension.CL_COMMAND_- Enables modification of the command-buffer, by default command-buffers are immutable. If set, commands in the command-buffer may be updated via clUpdateMutableCommandsKHR.BUFFER_ MUTABLE_ KHR provided by the
cl_khr_command_buffer_mutable_dispatchextension.The default value of this property is
0.CL_COMMAND_BUFFER_ MUTABLE_ DISPATCH_ ASSERTS_ KHR provided by the
cl_khr_command_buffer_mutable_dispatchextension.cl_mutable_dispatch_ asserts_ khr This is a bitfield and can be set to a combination of the following values:
CL_MUTABLE_- An assertion by the user that the number of work-groups of any ND-range kernel recorded in this command buffer will not be updated beyond the number defined when the ND-range kernel was recorded. If the user’s update to the values of local_work_size and/or global_work_size result in an increase in the number of work-groups in the ND-range over the number specified when the ND-range kernel was recorded, the behavior is undefined.DISPATCH_ ASSERT_ NO_ ADDITIONAL_ WORK_ GROUPS_ KHR provided by the
cl_khr_command_buffer_mutable_dispatchextension. -
errcode_ret will return an appropriate error code. If errcode_ret is
NULL, no error code is returned.
All Devices Associated With Queues can Device-side Sync |
Platform Supports Universal Sync | Condition | Result |
|---|---|---|---|
Yes |
Yes or No |
Any device does not support the multi-queue capability, and has more than one queue targeting it |
Error - |
User sets |
OK |
||
Otherwise |
OK |
||
No |
Yes |
Any device does not support the multi-queue capability, and has more than one queue targeting it |
Error - |
User sets |
Error - |
||
Otherwise |
OK - May be performance implications when synchronizing commands between devices without device-side sync support. |
||
No |
No |
Always |
Error - |
|
Upon creation the command-buffer is defined as being in the Recording state, in order for the command-buffer to be enqueued it must first be finalized using clFinalizeCommandBufferKHR after which no further commands can be recorded. A command-buffer is submitted for execution on command-queues with a call to clEnqueueCommandBufferKHR. |
clCreateCommandBufferKHR returns a valid non-zero command-buffer and
errcode_ret is set to CL_SUCCESS if the command-buffer is created
successfully.
Otherwise, it returns a NULL value with one of the following error values
returned in errcode_ret:
-
CL_INVALID_if any command-queue in queues is not a valid command-queue.COMMAND_ QUEUE -
CL_INVALID_if all the command-queues in queues do not have the same OpenCL context.CONTEXT -
CL_INVALID_if theVALUE cl_khr_extension is supported and num_queues is zero, or if thecommand_ buffer_ multi_ device cl_khr_extension is not supported and num_queues is not one.command_ buffer_ multi_ device -
CL_INVALID_if queues isVALUE NULL. -
CL_INVALID_if values specified in properties are not valid, or if the same property name is specified more than once.VALUE -
CL_INVALID_if values specified in properties are valid but are not supported by all the devices associated with command-queues in queues.PROPERTY -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the device.OF_ RESOURCES -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the host.OF_ HOST_ MEMORY
If the cl_khr_ extension is supported:
-
CL_INCOMPATIBLE_if queues includes more than one command-queue associated with a device that does not support capabilityCOMMAND_ QUEUE_ KHR CL_COMMAND_.BUFFER_ CAPABILITY_ MULTIPLE_ QUEUE_ KHR -
CL_INCOMPATIBLE_if theCOMMAND_ QUEUE_ KHR CL_COMMAND_flag is set, and any device associated with a command-queue in queues cannot natively synchronize with the other devices associated with queues as reported byBUFFER_ DEVICE_ SIDE_ SYNC_ KHR CL_DEVICE_.COMMAND_ BUFFER_ SYNC_ DEVICES_ KHR -
CL_INCOMPATIBLE_if the platform does not support theCOMMAND_ QUEUE_ KHR CL_COMMAND_capability, and any device associated with a command-queue in queues cannot natively synchronize with the other devices associated with queues as reported byBUFFER_ PLATFORM_ UNIVERSAL_ SYNC_ KHR CL_DEVICE_.COMMAND_ BUFFER_ SYNC_ DEVICES_ KHR
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.