[Openmp-commits] [PATCH] D144315: [OpenMP] Make isDone lightweight without calling synchronize
Ye Luo via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Fri Feb 17 18:46:07 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe2069be83ea8: [OpenMP] Make isDone lightweight without calling synchronize (authored by ye-luo).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144315/new/
https://reviews.llvm.org/D144315
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,13 +250,9 @@
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 (!*DoneOrErr)
+ if (!AsyncInfo->isDone())
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,13 +51,7 @@
return BufferLocations.back();
}
-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();
-}
+bool AsyncInfoTy::isDone() const { return isQueueEmpty(); }
int32_t AsyncInfoTy::runPostProcessing() {
size_t Size = PostProcessingFunctions.size();
Index: openmp/libomptarget/src/interface.cpp
===================================================================
--- openmp/libomptarget/src/interface.cpp
+++ openmp/libomptarget/src/interface.cpp
@@ -412,12 +412,11 @@
if (QueryCounter.isAboveThreshold())
AsyncInfo->SyncType = AsyncInfoTy::SyncTy::BLOCKING;
- auto DoneOrErr = AsyncInfo->isDone();
- if (!DoneOrErr)
+ if (const int Rc = AsyncInfo->synchronize())
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 (!*DoneOrErr) {
+ if (!AsyncInfo->isDone()) {
QueryCounter.increment();
return;
}
Index: openmp/libomptarget/include/omptarget.h
===================================================================
--- openmp/libomptarget/include/omptarget.h
+++ openmp/libomptarget/include/omptarget.h
@@ -17,7 +17,6 @@
#include <cstdint>
#include <deque>
#include <functional>
-#include <optional>
#include <stddef.h>
#include <stdint.h>
#include <type_traits>
@@ -244,12 +243,12 @@
/// Check if all asynchronous operations are completed.
///
- /// \note if the operations are completed, the registered post-processing
- /// functions will be executed once and unregistered afterwards.
+ /// \note only a lightweight check. If needed, use synchronize() to query the
+ /// status of AsyncInfo before checking.
///
/// \returns true if there is no pending asynchronous operations, false
- /// otherwise. We return a null value in the case of an error from the plugin.
- std::optional<bool> isDone();
+ /// otherwise.
+ bool isDone() const;
/// Add a new post-processing function to be executed after synchronization.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144315.498551.patch
Type: text/x-patch
Size: 3133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20230218/172837d4/attachment-0001.bin>
More information about the Openmp-commits
mailing list