[llvm] [Offload] Implement hasPendingWork on CUDA (PR #152728)
Callum Fare via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 07:10:25 PDT 2025
https://github.com/callumfare created https://github.com/llvm/llvm-project/pull/152728
Following on from #152304, implement the new query in the CUDA plugin
>From a51ac5cee23fcacf093e2475e5f3855de057a466 Mon Sep 17 00:00:00 2001
From: Callum Fare <callum at codeplay.com>
Date: Fri, 8 Aug 2025 15:08:43 +0100
Subject: [PATCH] [Offload] Implement hasPendingWork on CUDA
---
offload/plugins-nextgen/cuda/src/rtl.cpp | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/offload/plugins-nextgen/cuda/src/rtl.cpp b/offload/plugins-nextgen/cuda/src/rtl.cpp
index f3f3783b3ce7c..6ae17c4265894 100644
--- a/offload/plugins-nextgen/cuda/src/rtl.cpp
+++ b/offload/plugins-nextgen/cuda/src/rtl.cpp
@@ -914,9 +914,19 @@ struct CUDADeviceTy : public GenericDeviceTy {
return Plugin::check(Res, "error in cuStreamWaitEvent: %s");
}
- // TODO: This should be implementable on CUDA
Expected<bool> hasPendingWorkImpl(AsyncInfoWrapperTy &AsyncInfo) override {
- return true;
+ CUstream Stream;
+ if (auto Err = getStream(AsyncInfo, Stream))
+ return Err;
+
+ CUresult Ret = cuStreamQuery(Stream);
+ if (Ret == CUDA_SUCCESS)
+ return false;
+
+ if (Ret == CUDA_ERROR_NOT_READY)
+ return true;
+
+ return Plugin::check(Ret, "error in cuStreamQuery: %s");
}
/// Synchronize the current thread with the event.
More information about the llvm-commits
mailing list