[Openmp-commits] [openmp] [Libomptarget] Remove global ctor and use reference counting (PR #80499)

Johannes Doerfert via Openmp-commits openmp-commits at lists.llvm.org
Tue Feb 6 08:57:16 PST 2024


================
@@ -20,25 +20,37 @@
 extern void llvm::omp::target::ompt::connectLibrary();
 #endif
 
-__attribute__((constructor(101))) void init() {
+static std::mutex PluginMtx;
+static std::atomic<uint32_t> RefCount = 0;
----------------
jdoerfert wrote:

Rather put the counter into PM, and wrap PM into ProtectedObj? That makes it clear. I dislike complexity that is not needed, but I get why you went here. Still, this way one thinks the RefCount is accessed concurrently. ProtectedObj has benefits over a standalone Mtx too.

https://github.com/llvm/llvm-project/pull/80499


More information about the Openmp-commits mailing list