@@ -824,10 +824,11 @@ pi_result _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
824
824
CommandList->second .InUse = false ;
825
825
826
826
// Finally release/cleanup all the events in this command list.
827
+ // Note, we don't need to synchronize the events since the fence
828
+ // synchronized above already does that.
827
829
auto &EventList = CommandList->second .EventList ;
828
830
for (auto &Event : EventList) {
829
831
if (!Event->CleanedUp ) {
830
- ZE_CALL (zeHostSynchronize, (Event->ZeEvent ));
831
832
Event->cleanup (this );
832
833
}
833
834
Event->ZeCommandList = nullptr ;
@@ -1349,10 +1350,10 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
1349
1350
PI_ASSERT (EventList[I] != nullptr , PI_INVALID_VALUE);
1350
1351
auto ZeEvent = EventList[I]->ZeEvent ;
1351
1352
1352
- // Avoid polling of the device-scope events.
1353
- // TODO: be more fine-grain and check individual events.
1354
- if (FilterEventWaitList && ZeAllHostVisibleEvents ) {
1355
- auto Res = ZE_CALL_NOCHECK (zeEventQueryStatus, (ZeEvent ));
1353
+ // Poll of the host-visible events.
1354
+ auto ZeEventHostVisible = EventList[I]-> getHostVisibleEvent ();
1355
+ if (FilterEventWaitList && ZeEventHostVisible ) {
1356
+ auto Res = ZE_CALL_NOCHECK (zeEventQueryStatus, (ZeEventHostVisible ));
1356
1357
if (Res == ZE_RESULT_SUCCESS) {
1357
1358
// Event has already completed, don't put it into the list
1358
1359
continue ;
@@ -4510,7 +4511,7 @@ ze_event_handle_t _pi_event::getHostVisibleEvent() const {
4510
4511
} else if (ZeHostVisibleEvent) {
4511
4512
return ZeHostVisibleEvent;
4512
4513
} else {
4513
- die ( " The host-visible proxy event missing " ) ;
4514
+ return nullptr ;
4514
4515
}
4515
4516
}
4516
4517
@@ -4645,17 +4646,19 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName,
4645
4646
}
4646
4647
}
4647
4648
4648
- // Make sure that we query the host-visible event.
4649
- ze_event_handle_t ZeHostVisibleEvent;
4650
- if (auto Res = Event->getOrCreateHostVisibleEvent (ZeHostVisibleEvent))
4651
- return Res;
4652
-
4653
- ze_result_t ZeResult;
4654
- ZeResult = ZE_CALL_NOCHECK (zeEventQueryStatus, (ZeHostVisibleEvent));
4655
- if (ZeResult == ZE_RESULT_SUCCESS) {
4656
- return getInfo (ParamValueSize, ParamValue, ParamValueSizeRet,
4657
- pi_int32{CL_COMPLETE}); // Untie from OpenCL
4649
+ // Make sure that we query a host-visible event only.
4650
+ // If one wasn't yet created then don't create it here as well, and
4651
+ // just conservatively return that event is not yet completed.
4652
+ auto ZeHostVisibleEvent = Event->getHostVisibleEvent ();
4653
+ if (ZeHostVisibleEvent) {
4654
+ ze_result_t ZeResult;
4655
+ ZeResult = ZE_CALL_NOCHECK (zeEventQueryStatus, (ZeHostVisibleEvent));
4656
+ if (ZeResult == ZE_RESULT_SUCCESS) {
4657
+ return getInfo (ParamValueSize, ParamValue, ParamValueSizeRet,
4658
+ pi_int32{CL_COMPLETE}); // Untie from OpenCL
4659
+ }
4658
4660
}
4661
+
4659
4662
// TODO: We don't know if the status is queued, submitted or running.
4660
4663
// For now return "running", as others are unlikely to be of
4661
4664
// interest.
@@ -4886,6 +4889,9 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) {
4886
4889
4887
4890
for (uint32_t I = 0 ; I < NumEvents; I++) {
4888
4891
ze_event_handle_t ZeEvent = EventList[I]->getHostVisibleEvent ();
4892
+ if (!ZeEvent)
4893
+ die (" The host-visible proxy event missing" );
4894
+
4889
4895
zePrint (" ZeEvent = %#lx\n " , pi_cast<std::uintptr_t >(ZeEvent));
4890
4896
ZE_CALL (zeHostSynchronize, (ZeEvent));
4891
4897
0 commit comments