[llvm-branch-commits] [openmp] f57f59e - [Libomptarget] Check errors when synchronizing the async queue
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 20 00:34:41 PST 2023
Author: Joseph Huber
Date: 2023-02-20T09:33:18+01:00
New Revision: f57f59e5aebed3965019e884cc1d60bde97df192
URL: https://github.com/llvm/llvm-project/commit/f57f59e5aebed3965019e884cc1d60bde97df192
DIFF: https://github.com/llvm/llvm-project/commit/f57f59e5aebed3965019e884cc1d60bde97df192.diff
LOG: [Libomptarget] Check errors when synchronizing the async queue
Summary:
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
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D144191
(cherry picked from commit 5172877bbddc4e718e4bee57369c820d82f9a784)
Added:
Modified:
openmp/libomptarget/include/omptarget.h
openmp/libomptarget/src/interface.cpp
openmp/libomptarget/src/omptarget.cpp
openmp/libomptarget/src/private.h
Removed:
################################################################################
diff --git a/openmp/libomptarget/include/omptarget.h b/openmp/libomptarget/include/omptarget.h
index 9df9e2298236c..dd577e4051e21 100644
--- a/openmp/libomptarget/include/omptarget.h
+++ b/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>
@@ -247,8 +248,8 @@ class AsyncInfoTy {
/// functions will be executed once and unregistered afterwards.
///
/// \returns true if there is no pending asynchronous operations, false
- /// otherwise.
- bool isDone();
+ /// otherwise. We return a null value in the case of an error from the plugin.
+ std::optional<bool> isDone();
/// Add a new post-processing function to be executed after synchronization.
///
diff --git a/openmp/libomptarget/src/interface.cpp b/openmp/libomptarget/src/interface.cpp
index beea0c26210bc..45f499962e4d1 100644
--- a/openmp/libomptarget/src/interface.cpp
+++ b/openmp/libomptarget/src/interface.cpp
@@ -412,9 +412,12 @@ EXTERN void __tgt_target_nowait_query(void **AsyncHandle) {
if (QueryCounter.isAboveThreshold())
AsyncInfo->SyncType = AsyncInfoTy::SyncTy::BLOCKING;
+ auto DoneOrErr = AsyncInfo->isDone();
+ if (!DoneOrErr)
+ FATAL_MESSAGE0(1, "Error while querying the async queue for completion.\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;
}
diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index f3a570f89692e..221ba949b8ebb 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -51,8 +51,10 @@ void *&AsyncInfoTy::getVoidPtrLocation() {
return BufferLocations.back();
}
-bool AsyncInfoTy::isDone() {
- synchronize();
+std::optional<bool> AsyncInfoTy::isDone() {
+ if (synchronize() == OFFLOAD_FAIL)
+ return std::nullopt;
+
// The async info operations are completed when the internal queue is empty.
return isQueueEmpty();
}
diff --git a/openmp/libomptarget/src/private.h b/openmp/libomptarget/src/private.h
index 9f156192e1036..fe55355e62187 100644
--- a/openmp/libomptarget/src/private.h
+++ b/openmp/libomptarget/src/private.h
@@ -250,9 +250,13 @@ class TaskAsyncInfoWrapperTy {
if (AsyncInfo == &LocalAsyncInfo)
return;
+ auto DoneOrErr = AsyncInfo->isDone();
+ if (!DoneOrErr)
+ FATAL_MESSAGE0(1,
+ "Error while querying the async queue for completion.\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.
More information about the llvm-branch-commits
mailing list