|
38 | 38 |
|
39 | 39 | There is also a WaitEvent used by the `ur_exp_command_buffer_handle_t` class
|
40 | 40 | in the prefix to wait on any dependencies passed in the enqueue wait-list.
|
| 41 | + This WaitEvent is reset at the end of the suffix, along with reset commands |
| 42 | + to reset the L0 events used to implement the UR sync-points. |
41 | 43 |
|
42 | 44 | ┌──────────┬────────────────────────────────────────────────┬─────────┐
|
43 | 45 | │ Prefix │ Commands added to UR command-buffer by UR user │ Suffix │
|
|
47 | 49 | Prefix │Reset signal event │ Barrier waiting on wait event│
|
48 | 50 | └───────────────────┴──────────────────────────────┘
|
49 | 51 |
|
50 |
| - ┌─────────────────────────────────────────┐ |
51 |
| - Suffix │Signal the UR command-buffer signal event│ |
52 |
| - └─────────────────────────────────────────┘ |
53 |
| -
|
| 52 | + ┌─────────────────────────────────────────────┐──────────────┐ |
| 53 | + Suffix │Barrier waiting on sync-point event, │ Reset events │ |
| 54 | + │signalling the UR command-buffer signal event│ │ |
| 55 | + └─────────────────────────────────────────────┘──────────────┘ |
54 | 56 |
|
55 | 57 | For a call to `urCommandBufferEnqueueExp` with an event_list `EL`,
|
56 | 58 | command-buffer `CB`, and return event `RE` our implementation has to create
|
@@ -437,26 +439,31 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t CommandBuffer) {
|
437 | 439 |
|
438 | 440 | UR_APIEXPORT ur_result_t UR_APICALL
|
439 | 441 | urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t CommandBuffer) {
|
440 |
| - // Reset the L0 events we use for command-buffer internal sync-points to the |
441 |
| - // non-signalled state |
442 |
| - ZE2UR_CALL(zeCommandListAppendBarrier, |
443 |
| - (CommandBuffer->ZeCommandList, nullptr, 0, nullptr)); |
444 |
| - for (auto SyncPoint : CommandBuffer->SyncPoints) { |
445 |
| - ur_event_handle_t Event = SyncPoint.second; |
446 |
| - ZE2UR_CALL(zeCommandListAppendEventReset, |
447 |
| - (CommandBuffer->ZeCommandList, Event->ZeEvent)); |
| 442 | + // Create a list of events for our signal event to wait on |
| 443 | + const size_t NumEvents = CommandBuffer->SyncPoints.size(); |
| 444 | + std::vector<ze_event_handle_t> WaitEventList{NumEvents}; |
| 445 | + for (size_t i = 0; i < NumEvents; i++) { |
| 446 | + WaitEventList[i] = CommandBuffer->SyncPoints[i]->ZeEvent; |
448 | 447 | }
|
449 | 448 |
|
| 449 | + // Wait for all the user added commands to complete, and signal the |
| 450 | + // command-buffer signal-event when they are done. |
| 451 | + ZE2UR_CALL(zeCommandListAppendBarrier, |
| 452 | + (CommandBuffer->ZeCommandList, CommandBuffer->SignalEvent->ZeEvent, |
| 453 | + NumEvents, WaitEventList.data())); |
| 454 | + |
450 | 455 | // Reset the wait-event for the UR command-buffer that is signalled when its
|
451 | 456 | // submission dependencies have been satisfied.
|
452 | 457 | ZE2UR_CALL(zeCommandListAppendEventReset,
|
453 | 458 | (CommandBuffer->ZeCommandList, CommandBuffer->WaitEvent->ZeEvent));
|
454 | 459 |
|
455 |
| - // We need to append signal that will indicate that command-buffer has |
456 |
| - // finished executing. |
457 |
| - ZE2UR_CALL( |
458 |
| - zeCommandListAppendSignalEvent, |
459 |
| - (CommandBuffer->ZeCommandList, CommandBuffer->SignalEvent->ZeEvent)); |
| 460 | + // Reset the L0 events we use for command-buffer internal sync-points to the |
| 461 | + // non-signalled state |
| 462 | + for (auto Event : WaitEventList) { |
| 463 | + ZE2UR_CALL(zeCommandListAppendEventReset, |
| 464 | + (CommandBuffer->ZeCommandList, Event)); |
| 465 | + } |
| 466 | + |
460 | 467 | // Close the command list and have it ready for dispatch.
|
461 | 468 | ZE2UR_CALL(zeCommandListClose, (CommandBuffer->ZeCommandList));
|
462 | 469 | return UR_RESULT_SUCCESS;
|
|
0 commit comments