@@ -1568,6 +1568,9 @@ struct AMDGPUStreamTy {
15681568 // / actions for that and prior events.
15691569 Error synchronizeOn (AMDGPUEventTy &Event);
15701570
1571+ // / Return true if the event from this queue is complete
1572+ Expected<bool > isEventComplete (const AMDGPUEventTy &Event);
1573+
15711574 // / Query the stream and complete pending post actions if operations finished.
15721575 // / Return whether all the operations completed. This operation does not block
15731576 // / the calling thread.
@@ -1732,6 +1735,18 @@ Error AMDGPUStreamTy::synchronizeOn(AMDGPUEventTy &Event) {
17321735 return completeUntil (Event.RecordedSlot );
17331736}
17341737
1738+ Expected<bool > AMDGPUStreamTy::isEventComplete (const AMDGPUEventTy &Event) {
1739+ std::lock_guard<std::mutex> Lock (Mutex);
1740+ assert (Event.RecordedStream == this && " event is for a different stream" );
1741+
1742+ if (Event.RecordedSyncCycle < SyncCycle) {
1743+ return true ;
1744+ }
1745+ assert (Event.RecordedSyncCycle == SyncCycle && " event is from the future?" );
1746+
1747+ return !Slots[Event.RecordedSlot ].Signal ->load ();
1748+ }
1749+
17351750struct AMDGPUStreamManagerTy final
17361751 : GenericDeviceResourceManagerTy<AMDGPUResourceRef<AMDGPUStreamTy>> {
17371752 using ResourceRef = AMDGPUResourceRef<AMDGPUStreamTy>;
@@ -2666,6 +2681,13 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
26662681 return Query.takeError ();
26672682 }
26682683
2684+ Expected<bool > isEventCompleteImpl (void *EventPtr,
2685+ AsyncInfoWrapperTy &AsyncInfo) override {
2686+ AMDGPUEventTy *Event = reinterpret_cast <AMDGPUEventTy *>(EventPtr);
2687+ auto Stream = AsyncInfo.getQueueAs <AMDGPUStreamTy *>();
2688+ return Stream && Stream->isEventComplete (*Event);
2689+ }
2690+
26692691 // / Synchronize the current thread with the event.
26702692 Error syncEventImpl (void *EventPtr) override {
26712693 AMDGPUEventTy *Event = reinterpret_cast <AMDGPUEventTy *>(EventPtr);
0 commit comments