[Openmp-commits] [PATCH] D131089: [Libomptarget] Explicitly init / deinit libomptarget from the user

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 4 04:46:06 PDT 2022


jhuber6 added a comment.

In D131089#3699012 <https://reviews.llvm.org/D131089#3699012>, @JonChesterfield wrote:

> As written this is not thread safe. Does anything ensure __tgt_register_lib et al are only called from a single host thread? The atomic counter suggests it can be called from several

I actually wasn't sure about the threaded behavior of these initializers. Since they're called by the C runtime I wasn't sure if these could be ever called by multiple threads. Couldn't really find a good answer for that. I put the atomic there because I was thinking about it but then figured that it's not actually threaded but forgot to change it to a regular count.



================
Comment at: openmp/libomptarget/src/interface.cpp:28
 /// adds requires flags
-EXTERN void __tgt_register_requires(int64_t Flags) {
+EXTERN void __tgt_register_requires(int64_t Flag) {
   TIMESCOPE();
----------------
JonChesterfield wrote:
> Can this be called by multiple threads?
It's called from the user's initialization / deinitialization, I'm assuming those don't have multiple threads call them but I haven't found any standards saying for sure. I'm not sure if anything knows the threaded properties of LLVM variables in `@llvm.global_ctors`. Glibc claims itself is thread safe which I may assume extends to functions it calls, we don't get multiple calls to `main` right?


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