@@ -40,14 +40,14 @@ ur_result_t ur_queue_handle_legacy_t_::enqueueNativeCommandExp(
4040 // support is added
4141 UR_CALL (Queue->Context ->getAvailableCommandList (
4242 Queue, CommandList, UseCopyEngine, NumEventsInWaitList, phEventList));
43- ScopedCommandList Active{Queue, CommandList->first };
4443
4544 // TODO: do we need to create a unique command type for this?
4645 ze_event_handle_t ZeEvent = nullptr ;
4746 ur_event_handle_t InternalEvent;
4847 bool IsInternal = phEvent == nullptr ;
4948 ur_event_handle_t *Event = phEvent ? phEvent : &InternalEvent;
50- UR_CALL (createEventAndAssociateQueue (Queue, Event, UR_COMMAND_ENQUEUE_NATIVE_EXP,
49+ UR_CALL (createEventAndAssociateQueue (Queue, Event,
50+ UR_COMMAND_ENQUEUE_NATIVE_EXP,
5151 CommandList, IsInternal, false ));
5252 ZeEvent = (*Event)->ZeEvent ;
5353 (*Event)->WaitList = TmpWaitList;
@@ -58,12 +58,26 @@ ur_result_t ur_queue_handle_legacy_t_::enqueueNativeCommandExp(
5858 ZE2UR_CALL (zeCommandListAppendWaitOnEvents,
5959 (ZeCommandList, WaitList.Length , WaitList.ZeEventList ));
6060 }
61+
62+ if (!isInOrderQueue ()) {
63+ queueFinish ();
64+ // queue finish will execute the command list. Open it again so that
65+ // `zeCommandListAppendSignalEvent` can be executed.
66+ UR_CALL (Queue->Context ->getAvailableCommandList (
67+ Queue, CommandList, UseCopyEngine, NumEventsInWaitList, phEventList));
68+ }
69+ ScopedCommandList Active{Queue, CommandList->first };
70+
6171 // Execute interop func
6272 pfnNativeEnqueue (Queue, data);
6373
6474 ZE2UR_CALL (zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent));
6575
6676 UR_CALL (Queue->executeCommandList (CommandList, false ));
6777
78+ if (!isInOrderQueue ()) {
79+ queueFinish ();
80+ }
81+
6882 return UR_RESULT_SUCCESS;
6983}
0 commit comments