[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)
Kseniya Tikhomirova via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 20 03:32:23 PST 2025
================
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBSYCL_PLATFORM_IMPL
+#define _LIBSYCL_PLATFORM_IMPL
+
+#include <sycl/__impl/backend.hpp>
+#include <sycl/__impl/detail/config.hpp>
+#include <sycl/__impl/platform.hpp>
+
+#include "detail/offload/info_code.hpp"
+#include "detail/offload/offload_utils.hpp"
+
+#include <OffloadAPI.h>
+
+#include <memory>
+#include <string>
+#include <type_traits>
+#include <vector>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+namespace detail {
+
+class platform_impl {
+public:
+ /// Constructs platform_impl from a platform handle.
+ ///
+ /// \param Platform is a raw offload library handle representing platform.
+ /// \param PlatformIndex is a platform index in a backend (needed for a proper
+ /// indexing in device selector).
+ //
+ // Platforms can only be created under `GlobalHandler`'s ownership via
+ // `platform_impl::getOrMakePlatformImpl` method.
+ explicit platform_impl(ol_platform_handle_t Platform, size_t PlatformIndex);
+
+ ~platform_impl() = default;
+
+ /// Returns the backend associated with this platform.
+ backend getBackend() const noexcept { return MBackend; }
+
+ /// Returns all SYCL platforms from all backends that are available in the
+ /// system.
+ static std::vector<platform> getPlatforms();
----------------
KseniyaTikhomirova wrote:
done
https://github.com/llvm/llvm-project/pull/166927
More information about the llvm-commits
mailing list