@@ -732,12 +732,28 @@ class __SYCL_TYPE(multi_ptr) multi_ptr<void, Space, DecorateAddress> {
732732 decorated_type *m_Pointer;
733733};
734734
735+ namespace detail {
736+ // See access.hpp's DecoratedType<..., access::address_space::constant_space>.
737+ //
738+ // This is only applicable to `access::decorated::legacy` mode because constant
739+ // AS is deprecated itself and is only accessible in legacy modes.
740+ template <auto Space>
741+ #ifdef __SYCL_DEVICE_ONLY__
742+ inline constexpr auto decoration_space =
743+ deduce_AS<typename DecoratedType<void , Space>::type>::value;
744+ #else
745+ inline constexpr auto decoration_space = Space;
746+ #endif
747+ } // namespace detail
748+
735749// Legacy specialization of multi_ptr.
736750// TODO: Add deprecation warning here when possible.
737751template <typename ElementType, access::address_space Space>
738752class __SYCL2020_DEPRECATED (
739753 " decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
740754 multi_ptr<ElementType, Space, access::decorated::legacy> {
755+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
756+
741757public:
742758 using value_type = ElementType;
743759 using element_type =
@@ -777,7 +793,8 @@ class __SYCL2020_DEPRECATED(
777793
778794 multi_ptr (ElementType *pointer)
779795 : m_Pointer (detail::dynamic_address_cast<
780- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
796+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
797+ pointer)) {
781798 // TODO An implementation should reject an argument if the deduced
782799 // address space is not compatible with Space.
783800 }
@@ -786,7 +803,8 @@ class __SYCL2020_DEPRECATED(
786803 template <typename = typename detail::const_if_const_AS<Space, ElementType>>
787804 multi_ptr (const ElementType *pointer)
788805 : m_Pointer (detail::dynamic_address_cast<
789- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {}
806+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
807+ pointer)) {}
790808#endif
791809
792810 multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -814,7 +832,7 @@ class __SYCL2020_DEPRECATED(
814832 // TODO An implementation should reject an argument if the deduced
815833 // address space is not compatible with Space.
816834 m_Pointer = detail::dynamic_address_cast<
817- Space , /* SupressNotImplementedAssert = */ true >(pointer);
835+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
818836 return *this ;
819837 }
820838
@@ -856,8 +874,8 @@ class __SYCL2020_DEPRECATED(
856874 multi_ptr (accessor<ElementType, dimensions, Mode, target::device,
857875 isPlaceholder, PropertyListT>
858876 Accessor)
859- : multi_ptr (
860- detail::static_address_cast<Space>( Accessor.get_pointer ().get ())) {}
877+ : multi_ptr (detail::static_address_cast<DecorationSpace>(
878+ Accessor.get_pointer ().get ())) {}
861879
862880 // Only if Space == local_space || generic_space
863881 template <
@@ -1088,6 +1106,8 @@ template <access::address_space Space>
10881106class __SYCL2020_DEPRECATED (
10891107 " decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
10901108 multi_ptr<void , Space, access::decorated::legacy> {
1109+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
1110+
10911111public:
10921112 using value_type = void ;
10931113 using element_type = void ;
@@ -1113,17 +1133,17 @@ class __SYCL2020_DEPRECATED(
11131133 !std::is_same_v<RelayPointerT, void *>>>
11141134 multi_ptr (void *pointer)
11151135 : m_Pointer (detail::dynamic_address_cast<
1116- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
1136+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1137+ pointer)) {
11171138 // TODO An implementation should reject an argument if the deduced
11181139 // address space is not compatible with Space.
11191140 }
11201141#if defined(RESTRICT_WRITE_ACCESS_TO_CONSTANT_PTR)
11211142 template <typename = typename detail::const_if_const_AS<Space, void >>
11221143 multi_ptr (const void *pointer)
1123- : m_Pointer (
1124- detail::dynamic_address_cast<
1125- pointer_t , /* SupressNotImplementedAssert = */ true >(pointer)) {
1126- }
1144+ : m_Pointer (detail::dynamic_address_cast<
1145+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1146+ pointer)) {}
11271147#endif
11281148#endif
11291149 multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -1154,7 +1174,7 @@ class __SYCL2020_DEPRECATED(
11541174 // TODO An implementation should reject an argument if the deduced
11551175 // address space is not compatible with Space.
11561176 m_Pointer = detail::dynamic_address_cast<
1157- Space , /* SupressNotImplementedAssert = */ true >(pointer);
1177+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
11581178 return *this ;
11591179 }
11601180#endif
@@ -1249,6 +1269,8 @@ template <access::address_space Space>
12491269class __SYCL2020_DEPRECATED (
12501270 " decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
12511271 multi_ptr<const void , Space, access::decorated::legacy> {
1272+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
1273+
12521274public:
12531275 using value_type = const void ;
12541276 using element_type = const void ;
@@ -1275,15 +1297,17 @@ class __SYCL2020_DEPRECATED(
12751297 !std::is_same_v<RelayPointerT, const void *>>>
12761298 multi_ptr (const void *pointer)
12771299 : m_Pointer (detail::dynamic_address_cast<
1278- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
1300+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1301+ pointer)) {
12791302 // TODO An implementation should reject an argument if the deduced
12801303 // address space is not compatible with Space.
12811304 }
12821305#if defined(RESTRICT_WRITE_ACCESS_TO_CONSTANT_PTR)
12831306 template <typename = typename detail::const_if_const_AS<Space, void >>
12841307 multi_ptr (const void *pointer)
12851308 : m_Pointer (detail::dynamic_address_cast<
1286- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {}
1309+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1310+ pointer)) {}
12871311#endif
12881312#endif
12891313 multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -1314,7 +1338,7 @@ class __SYCL2020_DEPRECATED(
13141338 // TODO An implementation should reject an argument if the deduced
13151339 // address space is not compatible with Space.
13161340 m_Pointer = detail::dynamic_address_cast<
1317- pointer_t , /* SupressNotImplementedAssert = */ true >(pointer);
1341+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
13181342 return *this ;
13191343 }
13201344#endif
@@ -1442,7 +1466,7 @@ address_space_cast(ElementType *pointer) {
14421466 // space is not compatible with Space.
14431467 // Use LegacyPointerTypes here to also allow constant_space
14441468 return multi_ptr<ElementType, Space, DecorateAddress>(
1445- detail::dynamic_address_cast<Space,
1469+ detail::dynamic_address_cast<detail::decoration_space< Space> ,
14461470 /* SupressNotImplementedAssert = */ true >(
14471471 pointer));
14481472}
0 commit comments