@@ -667,46 +667,44 @@ urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t CommandBuffer) {
667667 return UR_RESULT_SUCCESS;
668668}
669669
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+
670677UR_APIEXPORT ur_result_t UR_APICALL
671678urCommandBufferFinalizeExp (ur_exp_command_buffer_handle_t CommandBuffer) {
672679 UR_ASSERT (CommandBuffer, UR_RESULT_ERROR_INVALID_NULL_POINTER);
673680 // It is not allowed to append to command list from multiple threads.
674681 std::scoped_lock<ur_shared_mutex> Guard (CommandBuffer->Mutex );
675682
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-
691683 if (CommandBuffer->IsInOrderCmdList ) {
692684 ZE2UR_CALL (zeCommandListAppendSignalEvent,
693685 (CommandBuffer->ZeComputeCommandList ,
694686 CommandBuffer->SignalEvent ->ZeEvent ));
695687 } 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)) ;
701693 }
702694
703695 // Wait for all the user added commands to complete, and signal the
704696 // 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 ()));
708702 }
709703
704+ ZE2UR_CALL (zeCommandListAppendSignalEvent,
705+ (CommandBuffer->ZeCommandListResetEvents ,
706+ CommandBuffer->AllResetEvent ->ZeEvent ));
707+
710708 // Close the command lists and have them ready for dispatch.
711709 ZE2UR_CALL (zeCommandListClose, (CommandBuffer->ZeComputeCommandList ));
712710 ZE2UR_CALL (zeCommandListClose, (CommandBuffer->ZeCommandListResetEvents ));
0 commit comments