[Openmp-commits] [PATCH] D142249: [openmp] Workaround for HSA in issue 60119

Mészáros Gergely via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 20 13:35:42 PST 2023


Maetveis added a comment.

This change avoids the deadlock, but now library registration happens before the device runtimes are loaded essentially skipping it.

In D142249#4070041 <https://reviews.llvm.org/D142249#4070041>, @jhuber6 wrote:

> Fails these tests. It seems we need to load the dynamic libraries multiple times because the plugin constructor is only called once.
>
>   libomptarget :: amdgcn-amd-amdhsa :: offloading/dynamic_module.c
>   libomptarget :: amdgcn-amd-amdhsa-LTO :: offloading/dynamic_module.c

They fail because the `__target_register_lib` calls from the shared library runs before `PM->RTLs.AllRTLs` is filled. The order of events should be this roughly:

1. `init()` starts executing
2. the amdgpu plugin initialization starts
3. the amdgpu plugin initializes HSA
4. HSA starts to dlopens objects. Importantly as far as I have seen `__attribute__((constructor))` functions will only run for the libraries that did not start them yet, e.g. `init()` does not get called again.
5. The user library is opened: since this is its first load its constructors are ran, including the call to `__tgt_register_lib`
6. the user library is not registered because the device plugin (step 2) is not loaded yet (we're currently nested inside


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142249



More information about the Openmp-commits mailing list