[Openmp-commits] [PATCH] D131089: [Libomptarget] Explicitly init / deinit libomptarget from the user
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Aug 4 06:50:28 PDT 2022
JonChesterfield added a comment.
This looks very error prone
> `void initLibomptarget(bool IncrementCount = true);`
How about we reference count this library consistently instead. Have the user code constructor that wants to call requires_flags increment the refcount before doing so and decrement the refcount when it goes out of scope. Likewise have whatever else wants to call into the library increment the refcount before using it and decrement when it goes out of scope. The code that currently emits a global ctor that calls requires_flags would also emit a global dtor that calls the destructor.
We still need the logic to have the first user do the initialisation while the others wait. I'd have probably gone with something along the lines of:
atomic count = 0;
if (count != 0) { return; }
lock_mutex
if (count != 0) { unlock; return; }
initialise();
count = 1
unlock; return
================
Comment at: openmp/libomptarget/src/rtl.cpp:52
+ if (IncrementCount)
+ LibraryUsers++;
+
----------------
Still broken. How are you testing this?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131089/new/
https://reviews.llvm.org/D131089
More information about the Openmp-commits
mailing list