@@ -667,46 +667,44 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t CommandBuffer) {
667
667
return UR_RESULT_SUCCESS;
668
668
}
669
669
670
+ void ur_exp_command_buffer_handle_t_::RegisterSyncPoint (
671
+ ur_exp_command_buffer_sync_point_t SyncPoint, ur_event_handle_t Event) {
672
+ SyncPoints[SyncPoint] = Event;
673
+ NextSyncPoint++;
674
+ ZeEventsList.push_back (Event->ZeEvent );
675
+ }
676
+
670
677
UR_APIEXPORT ur_result_t UR_APICALL
671
678
urCommandBufferFinalizeExp (ur_exp_command_buffer_handle_t CommandBuffer) {
672
679
UR_ASSERT (CommandBuffer, UR_RESULT_ERROR_INVALID_NULL_POINTER);
673
680
// It is not allowed to append to command list from multiple threads.
674
681
std::scoped_lock<ur_shared_mutex> Guard (CommandBuffer->Mutex );
675
682
676
- // Create a list of events for our signal event to wait on
677
- // This loop also resets the L0 events we use for command-buffer internal
678
- // sync-points to the non-signaled state.
679
- // This is required for multiple submissions.
680
- const size_t NumEvents = CommandBuffer->SyncPoints .size ();
681
- for (size_t i = 0 ; i < NumEvents; i++) {
682
- auto ZeEvent = CommandBuffer->SyncPoints [i]->ZeEvent ;
683
- CommandBuffer->ZeEventsList .push_back (ZeEvent);
684
- ZE2UR_CALL (zeCommandListAppendEventReset,
685
- (CommandBuffer->ZeCommandListResetEvents , ZeEvent));
686
- }
687
- ZE2UR_CALL (zeCommandListAppendSignalEvent,
688
- (CommandBuffer->ZeCommandListResetEvents ,
689
- CommandBuffer->AllResetEvent ->ZeEvent ));
690
-
691
683
if (CommandBuffer->IsInOrderCmdList ) {
692
684
ZE2UR_CALL (zeCommandListAppendSignalEvent,
693
685
(CommandBuffer->ZeComputeCommandList ,
694
686
CommandBuffer->SignalEvent ->ZeEvent ));
695
687
} else {
696
- // Create a list of events for our signal event to wait on
697
- const size_t NumEvents = CommandBuffer-> SyncPoints . size ();
698
- std::vector< ze_event_handle_t > WaitEventList{NumEvents};
699
- for ( size_t i = 0 ; i < NumEvents; i++) {
700
- WaitEventList[i] = CommandBuffer->SyncPoints [i]-> ZeEvent ;
688
+ // Reset the L0 events we use for command-buffer sync-points to the
689
+ // non-signaled state. This is required for multiple submissions.
690
+ for ( auto &Event : CommandBuffer-> ZeEventsList ) {
691
+ ZE2UR_CALL (zeCommandListAppendEventReset,
692
+ ( CommandBuffer->ZeCommandListResetEvents , Event)) ;
701
693
}
702
694
703
695
// Wait for all the user added commands to complete, and signal the
704
696
// command-buffer signal-event when they are done.
705
- ZE2UR_CALL (zeCommandListAppendBarrier, (CommandBuffer->ZeComputeCommandList ,
706
- CommandBuffer->SignalEvent ->ZeEvent ,
707
- NumEvents, WaitEventList.data ()));
697
+ ZE2UR_CALL (zeCommandListAppendBarrier,
698
+ (CommandBuffer->ZeComputeCommandList ,
699
+ CommandBuffer->SignalEvent ->ZeEvent ,
700
+ CommandBuffer->ZeEventsList .size (),
701
+ CommandBuffer->ZeEventsList .data ()));
708
702
}
709
703
704
+ ZE2UR_CALL (zeCommandListAppendSignalEvent,
705
+ (CommandBuffer->ZeCommandListResetEvents ,
706
+ CommandBuffer->AllResetEvent ->ZeEvent ));
707
+
710
708
// Close the command lists and have them ready for dispatch.
711
709
ZE2UR_CALL (zeCommandListClose, (CommandBuffer->ZeComputeCommandList ));
712
710
ZE2UR_CALL (zeCommandListClose, (CommandBuffer->ZeCommandListResetEvents ));
0 commit comments