[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 02:48:07 PDT 2022


JonChesterfield requested changes to this revision.
JonChesterfield added a comment.
This revision now requires changes to proceed.

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



================
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();
----------------
Can this be called by multiple threads?


================
Comment at: openmp/libomptarget/src/rtl.cpp:48
+  // The target library is initialized by the first user to need it.
+  if (LibraryUsers++)
+    return;
----------------
This is unsound if threaded. Only one will initialise, but the other will return thinking it has been initialised when it hasn't been


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