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

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 4 06:52:22 PDT 2022


tianshilei1992 added a comment.

In D131089#3699418 <https://reviews.llvm.org/D131089#3699418>, @jhuber6 wrote:

> In D131089#3699417 <https://reviews.llvm.org/D131089#3699417>, @tianshilei1992 wrote:
>
>> 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 don't think we need to worry about thread safe here. All initialization in `libomptarget` and plugins assume thread safe as they are right now (no lock is used).
>
> It makes the code messier, but it's not a huge burden. I guess the question is if it's on the user or the library to make sure that `libomptarget` is initialized correctly.

I can't come up with a scenario where `libomptarget` could be initialized multiple of times from multiple threads. If user `dlopen` `libomptarget` w/o guarding the thread safety, then I think the user should worry more about if that could break `libdl`. Here using `mutex` and `conditional_variable` are generally an overkill.


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