[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 17 05:43:24 PST 2025
================
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <sycl/__impl/detail/config.hpp>
+#include <sycl/__impl/detail/obj_base.hpp>
+
+#include <detail/global_objects.hpp>
+#include <detail/platform_impl.hpp>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+namespace detail {
+
+platform_impl *
+platform_impl::getOrMakePlatformImpl(ol_platform_handle_t Platform,
+ size_t PlatformIndex) {
+ const std::lock_guard<std::mutex> Guard(getPlatformMapMutex());
----------------
KseniyaTikhomirova wrote:
I don't consider this as legacy. This mutex protects container with platform_impl objects that are created by request. At the first request of platform/device creation we enumerate all liboffload platforms & devices and these data (liboffload handles) exists from the beginning to the end of program and don't require protection.
For the SYCL impl objects it doesn't make sense to create them for all available devices & platforms (depending on usage, we may create all of them, a few or just a single one). since platform & device creation is usually done outside application's hot path I don't think it is better to optimize this mutex by allocating unused SYCL RT objects.
https://github.com/llvm/llvm-project/pull/166927
More information about the llvm-commits
mailing list