[Openmp-commits] [PATCH] D144191: [Libomptarget] Check errors when synchronizing the async queue
Joseph Huber via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 16 07:53:25 PST 2023
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, ye-luo.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.
Currently when we synchronize the asynchronous queue for the plugins, we
ignore the return value. This is problematic because we will continue on
like nothing happened if the kernel fails.
Fixes https://github.com/llvm/llvm-project/issues/60814
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144191
Files:
openmp/libomptarget/include/omptarget.h
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/src/private.h
Index: openmp/libomptarget/src/private.h
===================================================================
--- openmp/libomptarget/src/private.h
+++ openmp/libomptarget/src/private.h
@@ -250,9 +250,12 @@
if (AsyncInfo == &LocalAsyncInfo)
return;
+ auto DoneOrErr = AsyncInfo->isDone();
+ if (!DoneOrErr)
+ FATAL_MESSAGE0(1, "Error while synchronizing the async queue\n");
// If the are device operations still pending, return immediately without
// deallocating the handle.
- if (!AsyncInfo->isDone())
+ if (!*DoneOrErr)
return;
// Delete the handle and unset it from the OpenMP task data.
Index: openmp/libomptarget/src/omptarget.cpp
===================================================================
--- openmp/libomptarget/src/omptarget.cpp
+++ openmp/libomptarget/src/omptarget.cpp
@@ -51,8 +51,10 @@
return BufferLocations.back();
}
-bool AsyncInfoTy::isDone() {
- synchronize();
+std::optional<bool> AsyncInfoTy::isDone() {
+ if (int Result = synchronize())
+ return std::nullopt;
+
// The async info operations are completed when the internal queue is empty.
return isQueueEmpty();
}
Index: openmp/libomptarget/src/interface.cpp
===================================================================
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -412,9 +412,12 @@
if (QueryCounter.isAboveThreshold())
AsyncInfo->SyncType = AsyncInfoTy::SyncTy::BLOCKING;
+ auto DoneOrErr = AsyncInfo->isDone();
+ if (!DoneOrErr)
+ FATAL_MESSAGE0(1, "Error while synchronizing the async queue\n");
// If there are device operations still pending, return immediately without
// deallocating the handle and increase the current thread query count.
- if (!AsyncInfo->isDone()) {
+ if (!*DoneOrErr) {
QueryCounter.increment();
return;
}
Index: openmp/libomptarget/include/omptarget.h
===================================================================
--- openmp/libomptarget/include/omptarget.h
+++ openmp/libomptarget/include/omptarget.h
@@ -17,6 +17,7 @@
#include <cstdint>
#include <deque>
#include <functional>
+#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <type_traits>
@@ -248,7 +249,7 @@
///
/// \returns true if there is no pending asynchronous operations, false
/// otherwise.
- bool isDone();
+ std::optional<bool> isDone();
/// Add a new post-processing function to be executed after synchronization.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144191.498022.patch
Type: text/x-patch
Size: 2501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230216/e33d74c7/attachment.bin>
More information about the Openmp-commits
mailing list