diff options
Diffstat (limited to 'offload/plugins-nextgen/cuda/src/rtl.cpp')
| -rw-r--r-- | offload/plugins-nextgen/cuda/src/rtl.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/offload/plugins-nextgen/cuda/src/rtl.cpp b/offload/plugins-nextgen/cuda/src/rtl.cpp index e94f3f6af7dd..82c9f9b706cb 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. |
