Skip to content

Commit 92229e5

Browse files
committed
Refactor command-buffer queue compatability
As proposed in KhronosGroup#1142 the PR changes the semantics of the command-queues parameters used for command-buffer creation and enqueue. The queues used on command-buffer creation now only inform the device and dependencies of commands, rather than restricting the properties set on the queues used for command-buffer enqueue. This is based ontop on the change in KhronosGroup#850 to add supported queue property semantics.
1 parent 322e74c commit 92229e5

5 files changed

+76
-61
lines changed

Diff for: api/cl_khr_command_buffer.asciidoc

+21-19
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ include::{generated}/meta/{refprefix}cl_khr_command_buffer.txt[]
1212
=== Other Extension Metadata
1313

1414
*Last Modified Date*::
15-
2024-10-02
15+
2024-12-13
1616
*IP Status*::
1717
No known IP claims.
1818
*Contributors*::
@@ -43,11 +43,6 @@ Command-buffers enable a reduction in overhead when enqueuing the same
4343
workload multiple times. By separating the command-queue setup from dispatch,
4444
the ability to replay a set of previously created commands is introduced.
4545

46-
The command-queues a command-buffer will be executed on can be set on replay via
47-
parameters to {clEnqueueCommandBufferKHR}, provided they are
48-
<<compatible, compatible>> with the command-queues used on command-buffer
49-
recording.
50-
5146
==== Background
5247

5348
On embedded devices where building a command stream accounts for a significant
@@ -74,7 +69,7 @@ or writes memory objects; or enqueues a native kernel, is not available for
7469
command-buffer recording. Finally commands recorded into a command buffer do
7570
not wait for or return event objects, these are instead replaced with
7671
device-side synchronization-point identifiers which enable out-of-order
77-
execution when enqueued on <<compatible, compatible>> command-queues.
72+
execution of the command-buffer commands.
7873

7974
Adding new entry-points for individual commands, rather than recording existing
8075
command-queue APIs with begin/end markers was a design decision made for the
@@ -102,16 +97,22 @@ following reasons:
10297

10398
==== Command Synchronization
10499

105-
Device-side {cl_sync_point_khr_TYPE} synchronization-points can be used within
106-
command-buffers to define command dependencies. This allows the commands of a
107-
command-buffer to execute out-of-order on a single <<compatible, compatible>>
108-
command-queue. The command-buffer itself has no inherent in-order/out-of-order
109-
property, this ordering is inferred from the command-queue used on command
110-
recording. {clEnqueueCommandBufferKHR} submissions to an out-of-order queue
111-
have the same execution semantics are other operations enqueued to an
112-
out-of-order queue, such as {clEnqueueFillBuffer}, where execution between
113-
enqueued operations may happen concurrently unless dependencies between the
114-
operations are expressed with events.
100+
The command-buffer object has no in-order/out-of-order property set on creation,
101+
it is out-of-order, and command ordering is defined by the dependencies set when
102+
commands are created. Command dependencies can be define in 3 ways:
103+
104+
1. Device-side {cl_sync_point_khr_TYPE} synchronization-points, providing an
105+
explicit list of the commands to depend on.
106+
2. Appending a {clCommandBarrierWithWaitListKHR} barrier command.
107+
3. Passing an in-order queue when creating the command, creating an implicit
108+
dependency on the any previous command created in the command-buffer using
109+
the same queue.
110+
111+
{clEnqueueCommandBufferKHR} submissions to an out-of-order queue have the same
112+
execution semantics are other operations enqueued to an out-of-order queue,
113+
such as {clEnqueueFillBuffer}, where execution between enqueued operations may
114+
happen concurrently unless dependencies between the operations are expressed
115+
with events.
115116

116117
The {cl_sync_point_khr_TYPE} type is defined as a `cl_uint`, giving a hard
117118
upper limit on the number of commands a command-buffer can hold as
@@ -464,5 +465,6 @@ features:
464465
* 0.9.5, 2024-07-24
465466
** Add a properties parameter to all command recording entry-points
466467
(provisional).
467-
* 0.9.6, 2024-10-02
468-
** Add device query for supported queue properties (provisional).
468+
* 0.9.6, 2024-12-13
469+
** Refactor queue compatability between command-buffer creation and enqueue
470+
(provisional).

Diff for: api/cl_khr_command_buffer_multi_device.asciidoc

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include::{generated}/meta/{refprefix}cl_khr_command_buffer_multi_device.txt[]
66
=== Other Extension Metadata
77

88
*Last Modified Date*::
9-
2023-04-30
9+
2024-12-13
1010
*IP Status*::
1111
No known IP claims.
1212
*Contributors*::
@@ -312,3 +312,6 @@ require it.
312312
* Revision 0.9.1, 2023-04-30
313313
** Added clCommandSVMMemcpyKHR and clCommandSVMMemFillKHR as affected
314314
functions (provisional).
315+
* Revision 0.9.2, 2024-12-13
316+
** Update clRemapCommandBufferKHR behavior to match cl_khr_command_buffer
317+
version 0.9.6 (provisional).

Diff for: api/opencl_platform_layer.asciidoc

+1-2
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ include::{generated}/api/version-notes/CL_COMMAND_BUFFER_PLATFORM_UNIVERSAL_SYNC
240240

241241
{CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR_anchor} - Platform
242242
supports the ability to create a deep copy of an existing
243-
command-buffer with the commands explicitly remapped to different,
244-
potentially <<compatible, incompatible>>, queues.
243+
command-buffer with the commands explicitly remapped to different queues.
245244

246245
include::{generated}/api/version-notes/CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR.asciidoc[]
247246

Diff for: api/opencl_runtime_layer.asciidoc

+49-38
Original file line numberDiff line numberDiff line change
@@ -13915,16 +13915,33 @@ of 0 or 1.
1391513915
The simultaneous use capability removes this restriction and allows
1391613916
command-buffers to have a <<pending_count, Pending Count>> greater than 1.
1391713917

13918-
[[compatible]]
1391913918
Command-buffers are created using an ordered list of command-queues that
13920-
commands are recorded to and execute on by default.
13921-
These command-queues can be replaced on command-buffer enqueue with
13922-
different command-queues, provided for each element in the replacement list
13923-
the substitute command-queue is compatible with the command-queue used on
13924-
command-buffer creation.
13925-
A _compatible_ command-queue is defined as a command-queue with
13926-
identical properties targeting the same device and in the same OpenCL
13927-
context.
13919+
commands are recorded to and execute on by default. All these queue objects
13920+
must share the same context, but may be associated with different devices when
13921+
the {cl_khr_command_buffer_multi_device_EXT} extension is supported.
13922+
13923+
When constructing a command-buffer by appending commands, the queue parameter
13924+
passed for the command being created is used to set the device with which the
13925+
command will be associated with, and also inform the scheduling of the command.
13926+
If the queue is an in-order queue, then an additional dependency is created on the
13927+
last command appended to the command-buffer using the same queue parameter. If
13928+
the queue is an out-of-order queue, then no extra dependencies on previous
13929+
commands using the same queue are created. All queue properties other than
13930+
{CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE} are ignored for the purposes of command
13931+
creation, with the exception of any vendor extension defined queue properties
13932+
that explcitly define semantics for this purpose.
13933+
13934+
The command-queues used on command-buffer creation must be replaced on
13935+
command-buffer enqueue with the command-queues to execute the command-buffer
13936+
on. These may be different command-queues, provided for each element the
13937+
substitute command-queue matches the device and context of the command-queue
13938+
used on command-buffer creation. Each command-queue in the enqueue list must
13939+
also have the minimum properties defined by
13940+
{CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR} and no properties
13941+
which are not reported by
13942+
{CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR}. These queue
13943+
properties have the same execution semantics for {clEnqueueCommandBufferKHR}
13944+
as other operations enqueued to the queue.
1392813945

1392913946
While constructing a command-buffer it is valid for the user to interleave
1393013947
calls to the same queue which create commands, such as
@@ -13988,7 +14005,7 @@ target the same device.
1398814005

1398914006
Commands recorded to different command-queues in the same command-buffer may
1399014007
be executed concurrently to each other unless synchronized explicitly with
13991-
sync-points.
14008+
sync-points, barrier commands, or in-order queue implicit dependencies.
1399214009
Ordering of other commands submitted to the same command-queues as used to
1399314010
enqueue a command-buffer is the responsibility of the programmer.
1399414011
A command-buffer enqueue spanning multiple queues can return an event to use
@@ -14189,12 +14206,6 @@ returned in _errcode_ret_:
1418914206

1419014207
* {CL_INVALID_COMMAND_QUEUE} if any command-queue in _queues_ is not a
1419114208
valid command-queue.
14192-
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if the properties of any command-queue
14193-
in _queues_ contains a property not specified by
14194-
{CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR}.
14195-
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if the properties of any
14196-
command-queue in _queues_ does not contain the minimum properties
14197-
specified by {CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR}.
1419814209
* {CL_INVALID_CONTEXT} if all the command-queues in _queues_ do not have
1419914210
the same OpenCL context.
1420014211
* {CL_INVALID_VALUE} if the {cl_khr_command_buffer_multi_device_EXT}
@@ -14327,10 +14338,10 @@ include::{generated}/api/protos/clEnqueueCommandBufferKHR.txt[]
1432714338
include::{generated}/api/version-notes/clEnqueueCommandBufferKHR.asciidoc[]
1432814339

1432914340
* _num_queues_ is the number of command-queues listed in _queues_.
14330-
* _queues_ is a pointer to an ordered list of command-queues <<compatible,
14331-
compatible>> with the command-queues used on recording.
14332-
_queues_ can be `NULL`, in which case the default command-queues used on
14333-
command-buffer creation are used and _num_queues_ must be 0.
14341+
* _queues_ is a pointer to an ordered list of command-queues to execute the
14342+
command-buffer on. _queues_ can be `NULL`, in which case the default
14343+
command-queues used on command-buffer creation are used and _num_queues_
14344+
must be 0.
1433414345
* _command_buffer_ refers to a valid command-buffer object.
1433514346
* _event_wait_list_, _num_events_in_wait_list_ specify events that need to
1433614347
complete before this particular command can be executed.
@@ -14375,9 +14386,15 @@ execution was successfully queued, or one of the errors below:
1437514386
_num_queues_ set on _command_buffer_ creation.
1437614387
* {CL_INVALID_COMMAND_QUEUE} if any element of _queues_ is not a valid
1437714388
command-queue.
14378-
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if any element of _queues_ is not
14379-
<<compatible, compatible>> with the command-queue set on
14380-
_command_buffer_ creation at the same list index.
14389+
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if the properties of any command-queue
14390+
in _queues_ contains a property not specified by
14391+
{CL_DEVICE_COMMAND_BUFFER_SUPPORTED_QUEUE_PROPERTIES_KHR}.
14392+
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if the properties of any
14393+
command-queue in _queues_ does not contain the minimum properties
14394+
specified by {CL_DEVICE_COMMAND_BUFFER_REQUIRED_QUEUE_PROPERTIES_KHR}.
14395+
* {CL_INVALID_DEVICE} if any element of _queues_ does not have the same
14396+
device as the command-queue set on _command_buffer_ creation at the
14397+
same list index.
1438114398
* {CL_INVALID_CONTEXT} if any element of _queues_ does not have the same
1438214399
context as the command-queue set on _command_buffer_ creation at the
1438314400
same list index.
@@ -15761,22 +15778,18 @@ ifdef::cl_khr_command_buffer_multi_device[]
1576115778
If the {cl_khr_command_buffer_multi_device_EXT} extension is supported,
1576215779
platforms reporting the {CL_COMMAND_BUFFER_PLATFORM_REMAP_QUEUES_KHR}
1576315780
capability support generating a deep copy of a command-buffer with its
15764-
commands remapped to a list of command-queues that are potentially
15765-
<<compatible, incompatible>> with the queues used to create the
15766-
command-buffer.
15767-
That is, the remapped command-buffer can execute on queues that differ in
15768-
terms of properties and/or associated device from the original
15781+
commands remapped to different devices than the devices used to create the
15782+
commands. That is, the remapped command-buffer can execute on queues that
15783+
differ in terms of properties and/or associated device from the original
1576915784
command-buffer queues.
1577015785

1577115786
This functionality is invoked through a new synchronous entry-point
1577215787
{clRemapCommandBufferKHR} which takes a list of queues to which the commands
15773-
should now target.
15774-
It then returns a command-buffer containing the same commands as the
15775-
original, with the same command dependencies, but targeting different
15776-
queues.
15777-
A list of command handles may also be passed to the entry-point, which
15778-
allows handles to the equivalent commands in the remapped command-buffer to
15779-
be returned by an output parameter.
15788+
should now target the associated devices of. It then returns a command-buffer
15789+
containing the same commands as the original, with the same command
15790+
dependencies, but targeting different devices. A list of command handles may
15791+
also be passed to the entry-point, which allows handles to the equivalent
15792+
commands in the remapped command-buffer to be returned by an output parameter.
1578015793

1578115794
Device properties restrict remapping possibilities, as existing commands can
1578215795
have a configuration which is not supported by another device, and so
@@ -15799,7 +15812,7 @@ appear and disappear during runtime.
1579915812
[open,refpage='clRemapCommandBufferKHR',desc='Create copy of a command-buffer remapped to specified command-queues',type='protos']
1580015813
--
1580115814
To create a deep copy of the input command-buffer with the copied commands
15802-
remapped to target the passed command-queues, call the function
15815+
remapped to target devices of the passed command-queues, call the function
1580315816

1580415817
include::{generated}/api/protos/clRemapCommandBufferKHR.txt[]
1580515818
include::{generated}/api/version-notes/clRemapCommandBufferKHR.asciidoc[]
@@ -15858,8 +15871,6 @@ one of the following error values returned in _errcode_ret_:
1585815871
* {CL_INVALID_OPERATION} if the platform does not support the
1585915872
{CL_COMMAND_BUFFER_PLATFORM_AUTOMATIC_REMAP_KHR} flag and _automatic_ is
1586015873
{CL_TRUE}.
15861-
* {CL_INCOMPATIBLE_COMMAND_QUEUE_KHR} if such an error would be returned
15862-
by passing _queues_ to {clCreateCommandBufferKHR}.
1586315874
* Any error relating to device support that can be returned by a command
1586415875
recording entry-point may also be returned.
1586515876
As a command in _command_buffer_ can have a configuration that is not

Diff for: xml/cl.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7406,7 +7406,7 @@ server's OpenCL/api-docs repository.
74067406
<enum name="CL_MEM_DEVICE_ID_INTEL"/>
74077407
</require>
74087408
</extension>
7409-
<extension name="cl_khr_command_buffer_multi_device" revision="0.9.1" supported="opencl" depends="cl_khr_command_buffer" ratified="opencl" provisional="true" comment="in sync with version 0.9.1; requires cl_khr_command_buffer 0.9.3 or later">
7409+
<extension name="cl_khr_command_buffer_multi_device" revision="0.9.2" supported="opencl" depends="cl_khr_command_buffer" ratified="opencl" provisional="true" comment="requires cl_khr_command_buffer 0.9.6 or later">
74107410
<require>
74117411
<type name="CL/cl.h"/>
74127412
</require>

0 commit comments

Comments
 (0)