Skip to content

Commit ead1579

Browse files
[SYCL] Fix SYCL-CTS regression after #15543 (#15931)
Apparently, we perform some hacks around constant address space that I wasn't aware of. Make sure new address cast helpers are called consistently with the previous behavior. --------- Co-authored-by: Sergey Semenov <[email protected]>
1 parent 966f054 commit ead1579

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

devops/cts_exclude_filter_L0_GPU

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ kernel_bundle
33
marray
44
# fix: https://github.com/KhronosGroup/SYCL-CTS/pull/964
55
accessor_legacy
6-
# CMPLRLLVM-62822
7-
multi_ptr

devops/cts_exclude_filter_OCL_CPU

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ math_builtin_api
77
hierarchical
88
# fix: https://github.com/KhronosGroup/SYCL-CTS/pull/964
99
accessor_legacy
10-
# CMPLRLLVM-62822
11-
multi_ptr

sycl/include/sycl/multi_ptr.hpp

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
737751
template <typename ElementType, access::address_space Space>
738752
class __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+
741757
public:
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>
10881106
class __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+
10911111
public:
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>
12491269
class __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+
12521274
public:
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
}

sycl/test-e2e/Basic/multi_ptr_legacy.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ template <typename T> void testMultPtrArrowOperator() {
157157
buffer<point<T>, 1> bufferData_2(data_2, numOfItems);
158158
buffer<point<T>, 1> bufferData_3(data_3, numOfItems);
159159
buffer<point<T>, 1> bufferData_4(data_4, numOfItems);
160+
buffer<bool, 1> result_buf{1};
160161
queue myQueue;
161162
myQueue.submit([&](handler &cgh) {
162163
accessor<point<T>, 1, access::mode::read, access::target::device,
@@ -170,8 +171,12 @@ template <typename T> void testMultPtrArrowOperator() {
170171
access::placeholder::false_t>
171172
accessorData_4(bufferData_4, cgh);
172173

174+
accessor result{result_buf, cgh};
175+
173176
cgh.parallel_for<class testMultPtrArrowOperatorKernel<T>>(
174177
sycl::nd_range<1>{1, 1}, [=](sycl::nd_item<1>) {
178+
// Initialize local memory:
179+
accessorData_3[0] = T{3};
175180
auto ptr_1 =
176181
make_ptr<const point<T>, access::address_space::global_space,
177182
access::decorated::legacy>(
@@ -195,6 +200,12 @@ template <typename T> void testMultPtrArrowOperator() {
195200
auto x3 = ptr_3->x;
196201
auto x4 = ptr_4->x;
197202

203+
result[0] = true;
204+
result[0] &= x1 == T{1};
205+
result[0] &= x2 == T{2};
206+
result[0] &= x3 == T{3};
207+
result[0] &= x4 == T{4};
208+
198209
static_assert(std::is_same<decltype(x1), T>::value,
199210
"Expected decltype(ptr_1->x) == T");
200211
static_assert(std::is_same<decltype(x2), T>::value,
@@ -205,6 +216,8 @@ template <typename T> void testMultPtrArrowOperator() {
205216
"Expected decltype(ptr_4->x) == T");
206217
});
207218
});
219+
220+
assert(sycl::host_accessor{result_buf}[0]);
208221
}
209222
}
210223

0 commit comments

Comments
 (0)