[llvm] [Offload] Don't create events for empty queues (PR #152304)

Ross Brunton via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 06:17:10 PDT 2025


================
@@ -2591,6 +2591,17 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
     return Event->wait(*Stream);
   }
 
+  Expected<bool> hasPendingWorkImpl(AsyncInfoWrapperTy &AsyncInfo) override {
+    auto Stream = AsyncInfo.getQueueAs<AMDGPUStreamTy *>();
+    if (!Stream)
+      return false;
+
+    auto Query = Stream->query();
----------------
RossBrunton wrote:

This has the side effect of performing cleanup required for the device (freeing any temporary memory, releasing signals, clearing the array, etc.) if the queue happens to be empty. I think this is fine and a sensible thing to do. It should have no observable side effects outside of the RTL.

https://github.com/llvm/llvm-project/pull/152304


More information about the llvm-commits mailing list