File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
libsycl/include/sycl/__impl Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1818#include < sycl/__impl/detail/config.hpp>
1919
2020#include < cassert>
21+ #include < optional>
2122#include < type_traits>
2223#include < utility>
2324
2425_LIBSYCL_BEGIN_NAMESPACE_SYCL
2526
2627namespace detail {
2728
28- template <class Impl , class SyclObject > class ObjBase {
29+ template <typename Impl, typename SyclObject> class ObjBase ;
30+ template <typename Impl, typename SyclObject>
31+ class ObjBase <Impl &, SyclObject> {
2932public:
3033 using ImplType = Impl;
31- using Base = ObjBase<Impl, SyclObject>;
34+ using Base = ObjBase<Impl & , SyclObject>;
3235
3336protected:
3437 ImplType &impl;
@@ -57,6 +60,19 @@ Obj createSyclObjFromImpl(
5760 return Obj::Base::createSyclProxy (ImplObj);
5861}
5962
63+ // std::hash support (4.5.2. Common reference semantics)
64+ template <typename T> struct HashBase {
65+ size_t operator ()(const T &Obj) const {
66+ #ifdef __SYCL_DEVICE_ONLY__
67+ (void )Obj;
68+ return 0 ;
69+ #else
70+ auto &Impl = sycl::detail::getSyclObjImpl (Obj);
71+ return std::hash<std::decay_t <decltype (Impl)>>{}(Impl);
72+ #endif
73+ }
74+ };
75+
6076} // namespace detail
6177
6278_LIBSYCL_END_NAMESPACE_SYCL
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class platform_impl;
3131
3232// 4.6.2. Platform class
3333class _LIBSYCL_EXPORT platform
34- : public detail::ObjBase<detail::platform_impl, platform> {
34+ : public detail::ObjBase<detail::platform_impl & , platform> {
3535public:
3636 // / Constructs a platform object that is a copy of the platform which contains
3737 // / the device returned by default_selector_v.
@@ -104,9 +104,13 @@ class _LIBSYCL_EXPORT platform
104104 typename detail::is_platform_info_desc<Param>::return_type
105105 get_info_impl () const ;
106106
107- friend detail::ObjBase<detail::platform_impl, platform>;
107+ friend detail::ObjBase<detail::platform_impl & , platform>;
108108}; // class platform
109109
110110_LIBSYCL_END_NAMESPACE_SYCL
111111
112+ template <>
113+ struct std ::hash<sycl::platform>
114+ : public sycl::detail::HashBase<sycl::platform> {};
115+
112116#endif // _LIBSYCL___IMPL_PLATFORM_HPP
You can’t perform that action at this time.
0 commit comments