[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)

Kseniya Tikhomirova via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 06:30:26 PST 2026


================
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <detail/global_objects.hpp>
+#include <detail/platform_impl.hpp>
+
+#ifdef _WIN32
+#  include <windows.h>
+#endif
+
+#include <vector>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+namespace detail {
+
+std::vector<detail::OffloadTopology> &getOffloadTopologies() {
+  static std::vector<detail::OffloadTopology> Topologies(
+      OL_PLATFORM_BACKEND_LAST);
+  return Topologies;
+}
+
+std::vector<PlatformImplUPtr> &getPlatformCache() {
+  static std::vector<PlatformImplUPtr> PlatformCache{};
+  return PlatformCache;
+}
+
+void shutdown() {
+  // No error reporting in shutdown
+  std::ignore = olShutDown();
+}
+
+#ifdef _WIN32
+extern "C" _LIBSYCL_EXPORT BOOL WINAPI DllMain(HINSTANCE hinstDLL,
+                                               DWORD fdwReason,
+                                               LPVOID lpReserved) {
+  // Perform actions based on the reason for calling.
+  switch (fdwReason) {
+  case DLL_PROCESS_DETACH:
+    try {
+      shutdown();
+    } catch (std::exception &e) {
+      // report
----------------
KseniyaTikhomirova wrote:

https://github.com/llvm/llvm-project/pull/166927/commits/2767396a123e74e4634993a2301f9168169daca2

https://github.com/llvm/llvm-project/pull/166927


More information about the llvm-commits mailing list