Skip to content

Commit d0f1514

Browse files
clarify CB Events Device assignment (#476)
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
1 parent eea5b2c commit d0f1514

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

scripts/core/PROG.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,7 @@ Key features
16121612
- ${x}EventHostSignal is not allowed. Can be signaled only from in-order command list
16131613
- No need to wait for completion before reusing/destroying
16141614
- CB Event doesn't own any memory allocations. Can be reused/destroyed with low cost. Timestamp allocation is also handled internally by the Driver
1615+
- A CB Event's device association is not fixed at creation. It re-associates with the signaling device on each signal operation. See `Device association`_.
16151616
- IPC sharing is one-directional. IPC CB Event opened in different process can be used only for waiting. If original Event state is changed (for example by next append call) and second process needs to see that update, IPC handle must be opened again.
16161617
- Regular command list (known as recorded or non-immediate) is a special use case for CB Events. Will be described in separate section
16171618
- When Event is reset (assigned as signal event to new append call), new timestamp data storage is provided implicitly. User can immediately query new data, without handling the completion
@@ -1634,6 +1635,21 @@ Regular Event rely on memory state controlled by the user (explicit Reset calls)
16341635
16351636
${x}EventHostSynchronize(event1, UINT32_MAX); // wait for counter=Y on memory CL3_alloc
16361637
1638+
Device association
1639+
^^^^^^^^^^^^^^^^^^^
1640+
Unlike Regular Events, a CB Event's device association is not fixed by the device passed to ${x}EventCounterBasedCreate. Its association follows the latest signaling point:
1641+
1642+
- After creation, the Event is associated with the device passed to ${x}EventCounterBasedCreate. This initial association does not restrict on which device the Event may later be signaled.
1643+
- When the Event is passed as a signal event to an append call, it drops its previous tracking point and re-associates with the device on which that command list was created. The Event may be signaled on any device, regardless of the device used to create it or the device that signaled it previously. No peer-to-peer access between the previous and the new signaling device is required.
1644+
- Waiting on the Event (for example ${x}CommandListAppendWaitOnEvents) does not change its association. The waiting device must have peer-to-peer access to the device that last had the Event enqueued for signaling (or, if the Event has not been enqueued for signaling yet, the device it is currently associated with).
1645+
1646+
.. parsed-literal::
1647+
${x}EventCounterBasedCreate(context, deviceA, &desc, &event); // associated with deviceA
1648+
${x}CommandListAppendSignalEvent(cmdListDeviceB, event); // re-associates with deviceB (no P2P deviceA<->deviceB required)
1649+
${x}CommandListAppendWaitOnEvents(cmdListDeviceC, 1, &event); // deviceC must have P2P access to deviceB
1650+
1651+
This is also the basis for IPC sharing: an opened IPC CB Event tracks the signaling device and can be waited on from any device that has peer-to-peer access to it.
1652+
16371653
IPC sharing
16381654
^^^^^^^^^^^
16391655
As mentioned previously, signaling CB Event replaces its state. This is why IPC sharing is one-directional. Opened event can be used only for waiting/querying (on host and GPU).

scripts/core/event.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ analogue:
492492
- "**clSetUserEventStatus**"
493493
- vkCmdSetEvent
494494
details:
495-
- "The application must ensure the events are accessible by the device on which the command list was created."
495+
- "The application must ensure the events are accessible by the device on which the command list was created. This requirement does not apply to counter-based events."
496+
- "For counter-based events, the event may be signaled on any device, regardless of the device used to create the event. When a counter-based event is passed for signaling, it drops its previous tracking point and re-associates with the device on which the command list was created, tracking the new signaling point. No peer-to-peer access between the previously associated device and the new signaling device is required."
496497
- "The duration of an event created from an event pool that was created using $X_EVENT_POOL_FLAG_KERNEL_TIMESTAMP or $X_EVENT_POOL_FLAG_KERNEL_MAPPED_TIMESTAMP flags is undefined. However, for consistency and orthogonality the event will report correctly as signaled when used by other event API functionality."
497498
- "The application must ensure the command list and events were created on the same context."
498499
- "The application must **not** call this function from simultaneous threads with the same command list handle."
@@ -513,6 +514,7 @@ class: $xCommandList
513514
name: AppendWaitOnEvents
514515
details:
515516
- "The application must ensure the events are accessible by the device on which the command list was created."
517+
- "For counter-based events, the device on which the command list was created must have peer-to-peer access to the device that last signaled the event. Unlike signaling, waiting on a counter-based event does not re-associate it with another device."
516518
- "The application must ensure the command list and events were created on the same context."
517519
- "The application must **not** call this function from simultaneous threads with the same command list handle."
518520
- "The implementation of this function should be lock-free."

0 commit comments

Comments
 (0)