@@ -40,14 +40,14 @@ ur_result_t ur_queue_handle_legacy_t_::enqueueNativeCommandExp(
40
40
// support is added
41
41
UR_CALL (Queue->Context ->getAvailableCommandList (
42
42
Queue, CommandList, UseCopyEngine, NumEventsInWaitList, phEventList));
43
- ScopedCommandList Active{Queue, CommandList->first };
44
43
45
44
// TODO: do we need to create a unique command type for this?
46
45
ze_event_handle_t ZeEvent = nullptr ;
47
46
ur_event_handle_t InternalEvent;
48
47
bool IsInternal = phEvent == nullptr ;
49
48
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,
51
51
CommandList, IsInternal, false ));
52
52
ZeEvent = (*Event)->ZeEvent ;
53
53
(*Event)->WaitList = TmpWaitList;
@@ -58,12 +58,26 @@ ur_result_t ur_queue_handle_legacy_t_::enqueueNativeCommandExp(
58
58
ZE2UR_CALL (zeCommandListAppendWaitOnEvents,
59
59
(ZeCommandList, WaitList.Length , WaitList.ZeEventList ));
60
60
}
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
+
61
71
// Execute interop func
62
72
pfnNativeEnqueue (Queue, data);
63
73
64
74
ZE2UR_CALL (zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent));
65
75
66
76
UR_CALL (Queue->executeCommandList (CommandList, false ));
67
77
78
+ if (!isInOrderQueue ()) {
79
+ queueFinish ();
80
+ }
81
+
68
82
return UR_RESULT_SUCCESS;
69
83
}
0 commit comments