[llvm-branch-commits] [llvm] [offload] Move AsyncInfoTy implementation from omptarget to PluginManager (PR #198101)
Ivan R. Ivanov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat May 16 08:13:23 PDT 2026
https://github.com/ivanradanov created https://github.com/llvm/llvm-project/pull/198101
<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
>From 0141e2898a5533f3f8300f4526beeaa4f37b6325 Mon Sep 17 00:00:00 2001
From: Ivan Radanov Ivanov <iivanov at nvidia.com>
Date: Sat, 16 May 2026 06:56:22 -0700
Subject: [PATCH] [offload] Move AsyncInfoTy implementation from omptarget to
PluginManager
---
offload/libompaccsupport/PluginManager.cpp | 49 ++++++++++++++++++++++
offload/libomptarget/omptarget.cpp | 49 ----------------------
2 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/offload/libompaccsupport/PluginManager.cpp b/offload/libompaccsupport/PluginManager.cpp
index 41b653a60adfd..3241a8ecc764f 100644
--- a/offload/libompaccsupport/PluginManager.cpp
+++ b/offload/libompaccsupport/PluginManager.cpp
@@ -30,6 +30,55 @@ PluginManager *PM = nullptr;
#define PLUGIN_TARGET(Name) extern "C" GenericPluginTy *createPlugin_##Name();
#include "Shared/Targets.def"
+int AsyncInfoTy::synchronize() {
+ int Result = OFFLOAD_SUCCESS;
+ if (!isQueueEmpty()) {
+ switch (SyncType) {
+ case SyncTy::BLOCKING:
+ // If we have a queue we need to synchronize it now.
+ Result = Device.synchronize(*this);
+ assert(AsyncInfo.Queue == nullptr &&
+ "The device plugin should have nulled the queue to indicate there "
+ "are no outstanding actions!");
+ break;
+ case SyncTy::NON_BLOCKING:
+ Result = Device.queryAsync(*this);
+ break;
+ }
+ }
+
+ // Run any pending post-processing function registered on this async object.
+ if (Result == OFFLOAD_SUCCESS && isQueueEmpty())
+ Result = runPostProcessing();
+
+ return Result;
+}
+
+void *&AsyncInfoTy::getVoidPtrLocation() {
+ BufferLocations.push_back(nullptr);
+ return BufferLocations.back();
+}
+
+bool AsyncInfoTy::isDone() const { return isQueueEmpty(); }
+
+int32_t AsyncInfoTy::runPostProcessing() {
+ size_t Size = PostProcessingFunctions.size();
+ for (size_t I = 0; I < Size; ++I) {
+ const int Result = PostProcessingFunctions[I]();
+ if (Result != OFFLOAD_SUCCESS)
+ return Result;
+ }
+
+ // Clear the vector up until the last known function, since post-processing
+ // procedures might add new procedures themselves.
+ const auto *PrevBegin = PostProcessingFunctions.begin();
+ PostProcessingFunctions.erase(PrevBegin, PrevBegin + Size);
+
+ return OFFLOAD_SUCCESS;
+}
+
+bool AsyncInfoTy::isQueueEmpty() const { return AsyncInfo.Queue == nullptr; }
+
void PluginManager::init() {
TIMESCOPE();
if (OffloadPolicy::isOffloadDisabled()) {
diff --git a/offload/libomptarget/omptarget.cpp b/offload/libomptarget/omptarget.cpp
index c2456920ebc1b..6853b7155e3ec 100644
--- a/offload/libomptarget/omptarget.cpp
+++ b/offload/libomptarget/omptarget.cpp
@@ -43,55 +43,6 @@ using namespace llvm::omp::target::ompt;
#endif
using namespace llvm::omp::target::debug;
-int AsyncInfoTy::synchronize() {
- int Result = OFFLOAD_SUCCESS;
- if (!isQueueEmpty()) {
- switch (SyncType) {
- case SyncTy::BLOCKING:
- // If we have a queue we need to synchronize it now.
- Result = Device.synchronize(*this);
- assert(AsyncInfo.Queue == nullptr &&
- "The device plugin should have nulled the queue to indicate there "
- "are no outstanding actions!");
- break;
- case SyncTy::NON_BLOCKING:
- Result = Device.queryAsync(*this);
- break;
- }
- }
-
- // Run any pending post-processing function registered on this async object.
- if (Result == OFFLOAD_SUCCESS && isQueueEmpty())
- Result = runPostProcessing();
-
- return Result;
-}
-
-void *&AsyncInfoTy::getVoidPtrLocation() {
- BufferLocations.push_back(nullptr);
- return BufferLocations.back();
-}
-
-bool AsyncInfoTy::isDone() const { return isQueueEmpty(); }
-
-int32_t AsyncInfoTy::runPostProcessing() {
- size_t Size = PostProcessingFunctions.size();
- for (size_t I = 0; I < Size; ++I) {
- const int Result = PostProcessingFunctions[I]();
- if (Result != OFFLOAD_SUCCESS)
- return Result;
- }
-
- // Clear the vector up until the last known function, since post-processing
- // procedures might add new procedures themselves.
- const auto *PrevBegin = PostProcessingFunctions.begin();
- PostProcessingFunctions.erase(PrevBegin, PrevBegin + Size);
-
- return OFFLOAD_SUCCESS;
-}
-
-bool AsyncInfoTy::isQueueEmpty() const { return AsyncInfo.Queue == nullptr; }
-
/* All begin addresses for partially mapped structs must be aligned, up to 16,
* in order to ensure proper alignment of members. E.g.
*
More information about the llvm-branch-commits
mailing list