[Openmp-commits] [PATCH] D142008: [libomptarget] Delay recursive shared library registrations until offload RTLs are loaded

Mészáros Gergely via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 20 04:57:33 PST 2023


Maetveis added a comment.

In D142008#4068271 <https://reviews.llvm.org/D142008#4068271>, @JonChesterfield wrote:

> I'm moderately surprised that ctors are called when dlopen opens something that is already open. Hopefully that's not platform specific.

The libraries are not yet "completely open" when HSA is iterating over them, they are mapped into the address space, but their "constructors" didn't run yet. HSA forces the initialization to happen immediately by the `dlopen` so their "constructor" are ran.

BTW, I was wrong in #4068088 <https://reviews.llvm.org/D142008#4068088>, a non-recursive lock can indeed work as long as it is not held locked while loading the device runtime shared libraries. My problem with adding libraries to the "to-be registered" list in other threads (not the one running `loadRTLs`) is that then those calls to `__tgt_register_lib` would return **before** the registration is done.

A recursive mutex + flag could work.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142008/new/

https://reviews.llvm.org/D142008



More information about the Openmp-commits mailing list