@@ -841,8 +841,10 @@ void _pi_queue::adjustBatchSizeForPartialBatch(pi_uint32 PartialBatchSize) {
841
841
842
842
pi_result _pi_queue::executeCommandList (ze_command_list_handle_t ZeCommandList,
843
843
ze_fence_handle_t ZeFence,
844
- bool IsBlocking,
844
+ pi_event Event, bool IsBlocking,
845
845
bool OKToBatchCommand) {
846
+ this ->LastCommandEvent = Event;
847
+
846
848
if (OKToBatchCommand && this ->isBatchingAllowed ()) {
847
849
if (this ->ZeOpenCommandList != nullptr &&
848
850
this ->ZeOpenCommandList != ZeCommandList)
@@ -906,7 +908,7 @@ pi_result _pi_queue::executeOpenCommandList() {
906
908
this ->ZeOpenCommandListFence = nullptr ;
907
909
this ->ZeOpenCommandListSize = 0 ;
908
910
909
- return executeCommandList (OpenList, OpenListFence);
911
+ return executeCommandList (OpenList, OpenListFence, this -> LastCommandEvent );
910
912
}
911
913
912
914
return PI_SUCCESS;
@@ -969,9 +971,9 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
969
971
}
970
972
}
971
973
972
- // For in-order queues, every command should be executed once after the
974
+ // For in-order queues, every command should be executed only after the
973
975
// previous command has finished. The event associated with the last
974
- // enqued command is added into the waitlist to ensure in-order semantics.
976
+ // enqueued command is added into the waitlist to ensure in-order semantics.
975
977
if (CurQueue->isInOrderQueue () && CurQueue->LastCommandEvent != nullptr ) {
976
978
this ->ZeEventList [TmpListLength] = CurQueue->LastCommandEvent ->ZeEvent ;
977
979
this ->PiEventList [TmpListLength] = CurQueue->LastCommandEvent ;
@@ -3841,11 +3843,10 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim,
3841
3843
pi_cast<std::uintptr_t >(ZeEvent));
3842
3844
printZeEventList ((*Event)->WaitList );
3843
3845
3844
- Queue->LastCommandEvent = *Event;
3845
-
3846
3846
// Execute command list asynchronously, as the event will be used
3847
3847
// to track down its completion.
3848
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, false , true ))
3848
+ if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, *Event,
3849
+ false , true ))
3849
3850
return Res;
3850
3851
3851
3852
return PI_SUCCESS;
@@ -4364,11 +4365,9 @@ pi_result piEnqueueEventsWait(pi_queue Queue, pi_uint32 NumEventsInWaitList,
4364
4365
4365
4366
ZE_CALL (zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent));
4366
4367
4367
- Queue->LastCommandEvent = *Event;
4368
-
4369
4368
// Execute command list asynchronously as the event will be used
4370
4369
// to track down its completion.
4371
- return Queue->executeCommandList (ZeCommandList, ZeFence);
4370
+ return Queue->executeCommandList (ZeCommandList, ZeFence, *Event );
4372
4371
}
4373
4372
4374
4373
// If wait-list is empty, then this particular command should wait until
@@ -4428,11 +4427,9 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue,
4428
4427
(ZeCommandList, ZeEvent, (*Event)->WaitList .Length ,
4429
4428
(*Event)->WaitList .ZeEventList ));
4430
4429
4431
- Queue->LastCommandEvent = *Event;
4432
-
4433
4430
// Execute command list asynchronously as the event will be used
4434
4431
// to track down its completion.
4435
- return Queue->executeCommandList (ZeCommandList, ZeFence);
4432
+ return Queue->executeCommandList (ZeCommandList, ZeFence, *Event );
4436
4433
}
4437
4434
4438
4435
pi_result piEnqueueMemBufferRead (pi_queue Queue, pi_mem Src,
@@ -4520,10 +4517,8 @@ static pi_result enqueueMemCopyHelper(pi_command_type CommandType,
4520
4517
pi_cast<std::uintptr_t >(ZeEvent));
4521
4518
printZeEventList (WaitList);
4522
4519
4523
- Queue->LastCommandEvent = *Event;
4524
-
4525
- if (auto Res =
4526
- Queue->executeCommandList (ZeCommandList, ZeFence, BlockingWrite))
4520
+ if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, *Event,
4521
+ BlockingWrite))
4527
4522
return Res;
4528
4523
4529
4524
return PI_SUCCESS;
@@ -4619,9 +4614,8 @@ static pi_result enqueueMemCopyRectHelper(
4619
4614
zePrint (" calling zeCommandListAppendBarrier() with Event %#lx\n " ,
4620
4615
pi_cast<std::uintptr_t >(ZeEvent));
4621
4616
4622
- Queue->LastCommandEvent = *Event;
4623
-
4624
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, Blocking))
4617
+ if (auto Res =
4618
+ Queue->executeCommandList (ZeCommandList, ZeFence, *Event, Blocking))
4625
4619
return Res;
4626
4620
4627
4621
return PI_SUCCESS;
@@ -4761,11 +4755,9 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr,
4761
4755
pi_cast<pi_uint64>(ZeEvent));
4762
4756
printZeEventList (WaitList);
4763
4757
4764
- Queue->LastCommandEvent = *Event;
4765
-
4766
4758
// Execute command list asynchronously, as the event will be used
4767
4759
// to track down its completion.
4768
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence))
4760
+ if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, *Event ))
4769
4761
return Res;
4770
4762
4771
4763
return PI_SUCCESS;
@@ -4905,9 +4897,8 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Buffer,
4905
4897
pi_cast<char *>(Buffer->getZeHandle ()) + Offset, Size , ZeEvent, 0 ,
4906
4898
nullptr ));
4907
4899
4908
- Queue->LastCommandEvent = *Event;
4909
-
4910
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, BlockingMap))
4900
+ if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, *Event,
4901
+ BlockingMap))
4911
4902
return Res;
4912
4903
4913
4904
return Buffer->addMapping (*RetMap, Offset, Size );
@@ -5017,11 +5008,9 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr,
5017
5008
pi_cast<char *>(MemObj->getZeHandle ()) + MapInfo.Offset , MappedPtr,
5018
5009
MapInfo.Size , ZeEvent, 0 , nullptr ));
5019
5010
5020
- Queue->LastCommandEvent = *Event;
5021
-
5022
5011
// Execute command list asynchronously, as the event will be used
5023
5012
// to track down its completion.
5024
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence))
5013
+ if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, *Event ))
5025
5014
return Res;
5026
5015
5027
5016
return PI_SUCCESS;
@@ -5215,9 +5204,8 @@ static pi_result enqueueMemImageCommandHelper(
5215
5204
return PI_INVALID_OPERATION;
5216
5205
}
5217
5206
5218
- Queue->LastCommandEvent = *Event;
5219
-
5220
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, IsBlocking))
5207
+ if (auto Res =
5208
+ Queue->executeCommandList (ZeCommandList, ZeFence, *Event, IsBlocking))
5221
5209
return Res;
5222
5210
5223
5211
return PI_SUCCESS;
@@ -5756,9 +5744,8 @@ pi_result piextUSMEnqueuePrefetch(pi_queue Queue, const void *Ptr, size_t Size,
5756
5744
// so manually add command to signal our event.
5757
5745
ZE_CALL (zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent));
5758
5746
5759
- Queue->LastCommandEvent = *Event;
5760
-
5761
- if (auto Res = Queue->executeCommandList (ZeCommandList, ZeFence, false ))
5747
+ if (auto Res =
5748
+ Queue->executeCommandList (ZeCommandList, ZeFence, *Event, false ))
5762
5749
return Res;
5763
5750
5764
5751
return PI_SUCCESS;
@@ -5815,13 +5802,11 @@ pi_result piextUSMEnqueueMemAdvise(pi_queue Queue, const void *Ptr,
5815
5802
ZE_CALL (zeCommandListAppendMemAdvise,
5816
5803
(ZeCommandList, Queue->Device ->ZeDevice , Ptr , Length, ZeAdvice));
5817
5804
5818
- Queue->LastCommandEvent = *Event;
5819
-
5820
5805
// TODO: Level Zero does not have a completion "event" with the advise API,
5821
5806
// so manually add command to signal our event.
5822
5807
ZE_CALL (zeCommandListAppendSignalEvent, (ZeCommandList, ZeEvent));
5823
5808
5824
- Queue->executeCommandList (ZeCommandList, ZeFence, false );
5809
+ Queue->executeCommandList (ZeCommandList, ZeFence, *Event, false );
5825
5810
return PI_SUCCESS;
5826
5811
}
5827
5812
0 commit comments