@@ -732,12 +732,28 @@ class __SYCL_TYPE(multi_ptr) multi_ptr<void, Space, DecorateAddress> {
732
732
decorated_type *m_Pointer;
733
733
};
734
734
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
+ }
748
+
735
749
// Legacy specialization of multi_ptr.
736
750
// TODO: Add deprecation warning here when possible.
737
751
template <typename ElementType, access::address_space Space>
738
752
class __SYCL2020_DEPRECATED (
739
753
" decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
740
754
multi_ptr<ElementType, Space, access::decorated::legacy> {
755
+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
756
+
741
757
public:
742
758
using value_type = ElementType;
743
759
using element_type =
@@ -777,7 +793,8 @@ class __SYCL2020_DEPRECATED(
777
793
778
794
multi_ptr (ElementType *pointer)
779
795
: m_Pointer (detail::dynamic_address_cast<
780
- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
796
+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
797
+ pointer)) {
781
798
// TODO An implementation should reject an argument if the deduced
782
799
// address space is not compatible with Space.
783
800
}
@@ -786,7 +803,8 @@ class __SYCL2020_DEPRECATED(
786
803
template <typename = typename detail::const_if_const_AS<Space, ElementType>>
787
804
multi_ptr (const ElementType *pointer)
788
805
: m_Pointer (detail::dynamic_address_cast<
789
- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {}
806
+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
807
+ pointer)) {}
790
808
#endif
791
809
792
810
multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -814,7 +832,7 @@ class __SYCL2020_DEPRECATED(
814
832
// TODO An implementation should reject an argument if the deduced
815
833
// address space is not compatible with Space.
816
834
m_Pointer = detail::dynamic_address_cast<
817
- Space , /* SupressNotImplementedAssert = */ true >(pointer);
835
+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
818
836
return *this ;
819
837
}
820
838
@@ -856,8 +874,8 @@ class __SYCL2020_DEPRECATED(
856
874
multi_ptr (accessor<ElementType, dimensions, Mode, target::device,
857
875
isPlaceholder, PropertyListT>
858
876
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 ())) {}
861
879
862
880
// Only if Space == local_space || generic_space
863
881
template <
@@ -1088,6 +1106,8 @@ template <access::address_space Space>
1088
1106
class __SYCL2020_DEPRECATED (
1089
1107
" decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
1090
1108
multi_ptr<void , Space, access::decorated::legacy> {
1109
+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
1110
+
1091
1111
public:
1092
1112
using value_type = void ;
1093
1113
using element_type = void ;
@@ -1113,17 +1133,17 @@ class __SYCL2020_DEPRECATED(
1113
1133
!std::is_same_v<RelayPointerT, void *>>>
1114
1134
multi_ptr (void *pointer)
1115
1135
: m_Pointer (detail::dynamic_address_cast<
1116
- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
1136
+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1137
+ pointer)) {
1117
1138
// TODO An implementation should reject an argument if the deduced
1118
1139
// address space is not compatible with Space.
1119
1140
}
1120
1141
#if defined(RESTRICT_WRITE_ACCESS_TO_CONSTANT_PTR)
1121
1142
template <typename = typename detail::const_if_const_AS<Space, void >>
1122
1143
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)) {}
1127
1147
#endif
1128
1148
#endif
1129
1149
multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -1154,7 +1174,7 @@ class __SYCL2020_DEPRECATED(
1154
1174
// TODO An implementation should reject an argument if the deduced
1155
1175
// address space is not compatible with Space.
1156
1176
m_Pointer = detail::dynamic_address_cast<
1157
- Space , /* SupressNotImplementedAssert = */ true >(pointer);
1177
+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
1158
1178
return *this ;
1159
1179
}
1160
1180
#endif
@@ -1249,6 +1269,8 @@ template <access::address_space Space>
1249
1269
class __SYCL2020_DEPRECATED (
1250
1270
" decorated::legacy multi_ptr specialization is deprecated since SYCL 2020." )
1251
1271
multi_ptr<const void , Space, access::decorated::legacy> {
1272
+ static constexpr auto DecorationSpace = detail::decoration_space<Space>;
1273
+
1252
1274
public:
1253
1275
using value_type = const void ;
1254
1276
using element_type = const void ;
@@ -1263,6 +1285,7 @@ class __SYCL2020_DEPRECATED(
1263
1285
1264
1286
static constexpr access ::address_space address_space = Space;
1265
1287
1288
+ public:
1266
1289
// Constructors
1267
1290
multi_ptr () : m_Pointer (nullptr ) {}
1268
1291
multi_ptr (const multi_ptr &) = default ;
@@ -1275,15 +1298,17 @@ class __SYCL2020_DEPRECATED(
1275
1298
!std::is_same_v<RelayPointerT, const void *>>>
1276
1299
multi_ptr (const void *pointer)
1277
1300
: m_Pointer (detail::dynamic_address_cast<
1278
- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {
1301
+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1302
+ pointer)) {
1279
1303
// TODO An implementation should reject an argument if the deduced
1280
1304
// address space is not compatible with Space.
1281
1305
}
1282
1306
#if defined(RESTRICT_WRITE_ACCESS_TO_CONSTANT_PTR)
1283
1307
template <typename = typename detail::const_if_const_AS<Space, void >>
1284
1308
multi_ptr (const void *pointer)
1285
1309
: m_Pointer (detail::dynamic_address_cast<
1286
- Space, /* SupressNotImplementedAssert = */ true >(pointer)) {}
1310
+ DecorationSpace, /* SupressNotImplementedAssert = */ true >(
1311
+ pointer)) {}
1287
1312
#endif
1288
1313
#endif
1289
1314
multi_ptr (std::nullptr_t ) : m_Pointer (nullptr ) {}
@@ -1314,7 +1339,7 @@ class __SYCL2020_DEPRECATED(
1314
1339
// TODO An implementation should reject an argument if the deduced
1315
1340
// address space is not compatible with Space.
1316
1341
m_Pointer = detail::dynamic_address_cast<
1317
- pointer_t , /* SupressNotImplementedAssert = */ true >(pointer);
1342
+ DecorationSpace , /* SupressNotImplementedAssert = */ true >(pointer);
1318
1343
return *this ;
1319
1344
}
1320
1345
#endif
@@ -1442,7 +1467,7 @@ address_space_cast(ElementType *pointer) {
1442
1467
// space is not compatible with Space.
1443
1468
// Use LegacyPointerTypes here to also allow constant_space
1444
1469
return multi_ptr<ElementType, Space, DecorateAddress>(
1445
- detail::dynamic_address_cast<Space,
1470
+ detail::dynamic_address_cast<detail::decoration_space< Space> ,
1446
1471
/* SupressNotImplementedAssert = */ true >(
1447
1472
pointer));
1448
1473
}
0 commit comments