[Openmp-commits] [PATCH] D99443: [OpenMP] Reset async stream properly upon failure
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Mar 26 14:18:35 PDT 2021
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
jhuber6 added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: openmp-commits, sstefan1.
If the call to `synchronize` fails, it will currently block the stream indefinitely if execution is continued from this point. Additionally, if the program exits it will trigger an assertion on the non-null value of the async queue and prevent the runtime from printing debugging information.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99443
Files:
openmp/libomptarget/plugins/cuda/src/rtl.cpp
Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===================================================================
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -1035,13 +1035,6 @@
int synchronize(const int DeviceId, __tgt_async_info *AsyncInfo) const {
CUstream Stream = reinterpret_cast<CUstream>(AsyncInfo->Queue);
CUresult Err = cuStreamSynchronize(Stream);
- if (Err != CUDA_SUCCESS) {
- REPORT("Error when synchronizing stream. stream = " DPxMOD
- ", async info ptr = " DPxMOD "\n",
- DPxPTR(Stream), DPxPTR(AsyncInfo));
- CUDA_ERR_STRING(Err);
- return OFFLOAD_FAIL;
- }
// Once the stream is synchronized, return it to stream pool and reset
// AsyncInfo. This is to make sure the synchronization only works for its
@@ -1050,7 +1043,13 @@
reinterpret_cast<CUstream>(AsyncInfo->Queue));
AsyncInfo->Queue = nullptr;
- return OFFLOAD_SUCCESS;
+ if (Err != CUDA_SUCCESS) {
+ REPORT("Error when synchronizing stream. stream = " DPxMOD
+ ", async info ptr = " DPxMOD "\n",
+ DPxPTR(Stream), DPxPTR(AsyncInfo));
+ CUDA_ERR_STRING(Err);
+ }
+ return (Err == CUDA_SUCCESS) ? OFFLOAD_SUCCESS : OFFLOAD_FAIL;
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99443.333630.patch
Type: text/x-patch
Size: 1332 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210326/b47e2f00/attachment.bin>
More information about the Openmp-commits
mailing list