[llvm] [Offload] Implement `olShutDown` (PR #144055)
Ross Brunton via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 27 08:52:31 PDT 2025
================
@@ -191,18 +193,41 @@ Error initPlugins() {
return Plugin::success();
}
-// TODO: We can properly reference count here and manage the resources in a more
-// clever way
Error olInit_impl() {
- static std::once_flag InitFlag;
- std::optional<Error> InitResult{};
- std::call_once(InitFlag, [&] { InitResult = initPlugins(); });
+ std::lock_guard<std::mutex> Lock{OffloadContextValMutex};
+
+ std::optional<Error> InitResult;
+ if (!isOffloadInitialized())
+ InitResult = initPlugins();
+
+ OffloadContext::get().RefCount++;
----------------
RossBrunton wrote:
The context is `new`'d in `initPlugins()`, but perhaps it makes sense doing it in `olInit_impl`, so I'll move it here.
https://github.com/llvm/llvm-project/pull/144055
More information about the llvm-commits
mailing list