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

Andrei Elovikov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 10:10:56 PST 2025


================
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains helper functions for tranformation between implementation
+/// and SYCL's interface objects.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBSYCL___IMPL_DETAIL_OBJ_BASE_HPP
+#define _LIBSYCL___IMPL_DETAIL_OBJ_BASE_HPP
+
+#include <sycl/__impl/detail/config.hpp>
+
+#include <cassert>
+#include <type_traits>
+#include <utility>
+
+_LIBSYCL_BEGIN_NAMESPACE_SYCL
+
+namespace detail {
+
+template <class Impl, class SyclObject> class ObjBase {
+public:
+  using ImplType = Impl;
+  using Base = ObjBase<Impl, SyclObject>;
+
+protected:
+  ImplType &impl;
+
+  explicit ObjBase(ImplType &pImpl) : impl(pImpl) {}
+  ObjBase() = default;
+
+  static SyclObject createSyclProxy(ImplType &impl) { return SyclObject(impl); }
+
+  template <class Obj>
+  friend const typename Obj::ImplType &getSyclObjImpl(const Obj &Object);
+
+  template <class Obj>
+  friend Obj createSyclObjFromImpl(
+      std::add_lvalue_reference_t<typename Obj::ImplType> ImplObj);
+};
----------------
aelovikov-intel wrote:

`std::hash` support should probably go here as well. We will require some boilerplate code to provide an actual specialization because C++20's

```c++
template <class T>
    requires(is_sycl_common_reference_semantics_class_v<T>)
struct std::hash<T> {
// sycl_obj_hash impl inlined here.
};
```

isn't available to us, but the implementation itself can be done generically here.

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


More information about the llvm-commits mailing list