@@ -1568,6 +1568,9 @@ struct AMDGPUStreamTy {
1568
1568
// / actions for that and prior events.
1569
1569
Error synchronizeOn (AMDGPUEventTy &Event);
1570
1570
1571
+ // / Return true if the event from this queue is complete
1572
+ Expected<bool > isEventComplete (const AMDGPUEventTy &Event);
1573
+
1571
1574
// / Query the stream and complete pending post actions if operations finished.
1572
1575
// / Return whether all the operations completed. This operation does not block
1573
1576
// / the calling thread.
@@ -1732,6 +1735,18 @@ Error AMDGPUStreamTy::synchronizeOn(AMDGPUEventTy &Event) {
1732
1735
return completeUntil (Event.RecordedSlot );
1733
1736
}
1734
1737
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
+
1735
1750
struct AMDGPUStreamManagerTy final
1736
1751
: GenericDeviceResourceManagerTy<AMDGPUResourceRef<AMDGPUStreamTy>> {
1737
1752
using ResourceRef = AMDGPUResourceRef<AMDGPUStreamTy>;
@@ -2666,6 +2681,13 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
2666
2681
return Query.takeError ();
2667
2682
}
2668
2683
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
+
2669
2691
// / Synchronize the current thread with the event.
2670
2692
Error syncEventImpl (void *EventPtr) override {
2671
2693
AMDGPUEventTy *Event = reinterpret_cast <AMDGPUEventTy *>(EventPtr);
0 commit comments