[Openmp-commits] [openmp] [Libomptarget] Remove remaining global constructors in plugins (PR #75814)
Joseph Huber via Openmp-commits
openmp-commits at lists.llvm.org
Mon Dec 18 08:07:04 PST 2023
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/75814
>From b6e04ce7f6f13581559d6c8b1ada071ca8f395ba Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 18 Dec 2023 09:42:30 -0600
Subject: [PATCH 1/2] [Libomptarget] Remove remaining global constructors in
plugins
Summary:
This patch fixes the remaining global constructor in the plguins after
addressing the ones in the JIT interface. This struct was mistakenly
using global constructors as not all the members were being initialized
properly. This was almost certainly being optimized out because it's
trivial, but would still be present in debug builds and prevented us
from compiling with `-Werror=global-constructors`. We will want to do
that once offloading is moved to a runtimes only build.
---
.../common/src/PluginInterface.cpp | 23 ++++++++++---------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
index 3c7d1ca8998787..d51575a87949ca 100644
--- a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
@@ -49,15 +49,15 @@ struct RecordReplayTy {
private:
// Memory pointers for recording, replaying memory.
- void *MemoryStart;
- void *MemoryPtr;
- size_t MemorySize;
- size_t TotalSize;
- GenericDeviceTy *Device;
- std::mutex AllocationLock;
-
- RRStatusTy Status;
- bool ReplaySaveOutput;
+ void *MemoryStart = nullptr;
+ void *MemoryPtr = nullptr;
+ size_t MemorySize = 0;
+ size_t TotalSize = 0;
+ GenericDeviceTy *Device = nullptr;
+ std::mutex AllocationLock{};
+
+ RRStatusTy Status = RRDeactivated;
+ bool ReplaySaveOutput = false;
bool UsedVAMap = false;
uintptr_t MemoryOffset = 0;
@@ -190,7 +190,7 @@ struct RecordReplayTy {
void setStatus(RRStatusTy Status) { this->Status = Status; }
bool isSaveOutputEnabled() const { return ReplaySaveOutput; }
- RecordReplayTy()
+ constexpr RecordReplayTy()
: Status(RRStatusTy::RRDeactivated), ReplaySaveOutput(false) {}
void saveImage(const char *Name, const DeviceImageTy &Image) {
@@ -352,8 +352,9 @@ struct RecordReplayTy {
Device->free(MemoryStart);
}
}
+};
-} RecordReplay;
+static RecordReplayTy RecordReplay;
// Extract the mapping of host function pointers to device function pointers
// from the entry table. Functions marked as 'indirect' in OpenMP will have
>From b1ae245817e7b5896d52713e5ba5bea802d4db82 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 18 Dec 2023 10:06:49 -0600
Subject: [PATCH 2/2] Remove {}
---
.../libomptarget/plugins-nextgen/common/src/PluginInterface.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
index d51575a87949ca..f92a0f6225775a 100644
--- a/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp
@@ -54,7 +54,7 @@ struct RecordReplayTy {
size_t MemorySize = 0;
size_t TotalSize = 0;
GenericDeviceTy *Device = nullptr;
- std::mutex AllocationLock{};
+ std::mutex AllocationLock;
RRStatusTy Status = RRDeactivated;
bool ReplaySaveOutput = false;
More information about the Openmp-commits
mailing list