You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Regular command list is a special use case for CB Events. Its state is additionally updated on every `zeCommandQueueExecuteCommandLists` call.
161
162
Any API call that relies on explicit counter memory/value (eg. `zexEventGetDeviceAddress`) needs to be called again to obtain new data. This includes IPC.
162
-
Other API calls that don't specify counter explicitly, are managed by the Driver.
163
+
Other API calls that don't specify counter explicitly, are managed by the Driver.
164
+
165
+
**Each regular command list execution updates state of the events that will be signaled in that command list to "not ready".**
166
+
**This rule applies to `zeCommandQueueExecuteCommandLists` and `zeCommandListImmediateAppendCommandListsExp` API calls.**
163
167
164
168
```cpp
165
169
// in-order operations
@@ -182,3 +186,46 @@ zeCommandQueueExecuteCommandLists(cmdQueue, 1, ®ularCmdList1, nullptr); // Co
182
186
// execute regularCmdList2 2nd time
183
187
zeCommandQueueExecuteCommandLists(cmdQueue, 1, ®ularCmdList2, nullptr); // wait for counter=8
184
188
```
189
+
190
+
# Multi directional dependencies on Regular command lists
191
+
Regular command list with overlapping dependencies may be executed multiple times. For example, two command lists are executed in parallel with bi-directional dependencies.
192
+
Its important to understand counter (Event) state transition, to correctly reflect Users intention.
193
+
194
+
```
195
+
regularCmdList1: (A) -------------> (wait for B) -----> (C)
196
+
| ^
197
+
| |
198
+
V |
199
+
regularCmdList2: (wait for A) -------------> (B) -----> (D)
200
+
```
201
+
202
+
In this example, all Events are synchronized to "ready" state after the first execution.
203
+
It means that second execution of `regularCmdList1` waits again for "ready" `{1->2->3}` state of `regularCmdList2` (first execution) instead of `{4->5->6}`.
204
+
This is because `regularCmdList2` was not yet executed for the second time. And their counters were not updated.
205
+
206
+
**First execution:**
207
+
```cpp
208
+
// All Events are in "not ready" state
209
+
zeCommandQueueExecuteCommandLists(cmdQueue1, 1, ®ularCmdList1, nullptr); // Counter updated to {1->2->3}
210
+
zeCommandQueueExecuteCommandLists(cmdQueue2, 1, ®ularCmdList2, nullptr); // Counter updated to {1->2->3}
211
+
212
+
// All Events are "ready" now
213
+
zeCommandQueueSynchronize(cmdQueue1, timeout); // wait for counter=3
214
+
zeCommandQueueSynchronize(cmdQueue2, timeout); // wait for counter=3
215
+
```
216
+
217
+
**Second execution:**
218
+
```cpp
219
+
// regularCmdList1 waits for "ready" {1->2->3} Events from first execution of regularCmdList2
220
+
// regularCmdList1 changes Events state to "not ready"
221
+
zeCommandQueueExecuteCommandLists(cmdQueue1, 1, ®ularCmdList1, nullptr); // Counter updated to {4->5->6}
222
+
223
+
// regularCmdList2 waits for "not ready" {4->5->6} Events from second execution of regularCmdList1
224
+
zeCommandQueueExecuteCommandLists(cmdQueue2, 1, ®ularCmdList2, nullptr); // Counter updated to {4->5->6}
225
+
```
226
+
227
+
**Different approach:**
228
+
229
+
To avoid above situation, User must remove all bi-directional dependencies. By using single command list (if possible) or split the workload into different command lists with single-directional dependencies.
230
+
231
+
Using Counter Based Events for such scenarios is not always the most optimal usage mode. It may be better to use Regular Events with explicit Reset calls.
0 commit comments