[llvm] [SYCL] Add platform enumeration and info query using liboffload (PR #166927)
Andrei Elovikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 18 22:19:24 PST 2025
================
@@ -15,15 +15,96 @@
#ifndef _LIBSYCL___IMPL_PLATFORM_HPP
#define _LIBSYCL___IMPL_PLATFORM_HPP
+#include <sycl/__impl/backend.hpp>
#include <sycl/__impl/detail/config.hpp>
+#include <sycl/__impl/detail/obj_base.hpp>
+#include <sycl/__impl/info/platform.hpp>
+
+#include <memory>
+#include <vector>
_LIBSYCL_BEGIN_NAMESPACE_SYCL
-class _LIBSYCL_EXPORT platform {
+namespace detail {
+class platform_impl;
+} // namespace detail
+
+// 4.6.2. Platform class
+class _LIBSYCL_EXPORT platform
+ : public detail::ObjBase<detail::platform_impl, platform> {
public:
- /// Constructs a SYCL platform which contains the default device.
- platform();
+ /// Constructs a platform object that is a copy of the platform which contains
+ /// the device returned by default_selector_v.
+ // platform();
+
+ /// Constructs a platform object that is a copy of the platform which contains
+ /// the device that is selected by selector.
+ /// \param DeviceSelectorInstance is SYCL 2020 Device Selector, a simple
+ /// callable taking a device reference and returning an integer rank.
+ // template <typename DeviceSelector>
+ // explicit platform(const DeviceSelector& DeviceSelectorInstance);
+
+ /// Returns the backend associated with this platform.
+ ///
+ /// \return the backend associated with this platform
+ backend get_backend() const noexcept;
+
+ /// Returns all SYCL devices associated with this platform.
+ ///
+ /// If there are no devices that match given device
+ /// type, resulting vector is empty.
+ ///
+ /// \param DeviceType is a SYCL device type.
+ /// \return a vector of SYCL devices.
+ // std::vector<device>
+ // get_devices(info::device_type DeviceType = info::device_type::all)
+ // const;
+
+ /// Queries this SYCL platform for info.
+ ///
+ /// The return type depends on information being queried.
+ template <typename Param>
+ typename detail::is_platform_info_desc<Param>::return_type get_info() const {
+ return get_info_impl<Param>();
+ }
----------------
aelovikov-intel wrote:
And why is `get_info_impl` needed at all? I'd expect it's just the leftover from our downstream `_GLIBCXX_USE_CXX11_ABI == 0` support.
https://github.com/llvm/llvm-project/pull/166927
More information about the llvm-commits
mailing list