@@ -824,10 +824,11 @@ pi_result _pi_queue::resetCommandList(pi_command_list_ptr_t CommandList,
824824 CommandList->second .InUse = false ;
825825
826826 // 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.
827829 auto &EventList = CommandList->second .EventList ;
828830 for (auto &Event : EventList) {
829831 if (!Event->CleanedUp ) {
830- ZE_CALL (zeHostSynchronize, (Event->ZeEvent ));
831832 Event->cleanup (this );
832833 }
833834 Event->ZeCommandList = nullptr ;
@@ -1349,10 +1350,10 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList(
13491350 PI_ASSERT (EventList[I] != nullptr , PI_INVALID_VALUE);
13501351 auto ZeEvent = EventList[I]->ZeEvent ;
13511352
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 ));
13561357 if (Res == ZE_RESULT_SUCCESS) {
13571358 // Event has already completed, don't put it into the list
13581359 continue ;
@@ -4510,7 +4511,7 @@ ze_event_handle_t _pi_event::getHostVisibleEvent() const {
45104511 } else if (ZeHostVisibleEvent) {
45114512 return ZeHostVisibleEvent;
45124513 } else {
4513- die ( " The host-visible proxy event missing " ) ;
4514+ return nullptr ;
45144515 }
45154516}
45164517
@@ -4645,17 +4646,19 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName,
46454646 }
46464647 }
46474648
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+ }
46584660 }
4661+
46594662 // TODO: We don't know if the status is queued, submitted or running.
46604663 // For now return "running", as others are unlikely to be of
46614664 // interest.
@@ -4886,6 +4889,9 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) {
48864889
48874890 for (uint32_t I = 0 ; I < NumEvents; I++) {
48884891 ze_event_handle_t ZeEvent = EventList[I]->getHostVisibleEvent ();
4892+ if (!ZeEvent)
4893+ die (" The host-visible proxy event missing" );
4894+
48894895 zePrint (" ZeEvent = %#lx\n " , pi_cast<std::uintptr_t >(ZeEvent));
48904896 ZE_CALL (zeHostSynchronize, (ZeEvent));
48914897
0 commit comments