[Openmp-commits] [PATCH] D120089: [OpenMP] Explicitly deinitialize device resources

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Mar 7 07:49:11 PST 2022


jdoerfert marked an inline comment as done.
jdoerfert added inline comments.


================
Comment at: openmp/libomptarget/plugins/cuda/src/rtl.cpp:590
 
+    assert(InitializedFlags[DeviceId] == false && "Reinitializing device!");
+    InitializedFlags[DeviceId] = true;
----------------
tianshilei1992 wrote:
> Actually this could have data race. Say if multiple threads are trying to initialize it at the same time. I don't remember we have the guard in `libomptarget`. We could potentially use `std::vector<std::once_flag>` instead.
This is something libomptarget should handle. There is little reason N plugins should do it and also little reason to assume plugins should allow concurrent initialization of the same device. That said, `DeviceTy::init()` in `libomptarget` is guarded by a `std::call_once` which should do the trick just fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120089



More information about the Openmp-commits mailing list