Skip to content

Commit da7dcf8

Browse files
authored
[SYCL][ABI-Break] Support accessor property interface (#6614)
SYCL 2020 defines a common property interface for accessor and host_accessor. Currently the DPC++ implementation of these classes take property list as a constructor argument but does not store them. In order to add the remaining interfaces the property lists must be stored on accessor and host_accessor, which is likely to break ABI.
1 parent 82aa804 commit da7dcf8

File tree

7 files changed

+97
-20
lines changed

7 files changed

+97
-20
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ set(SYCL_MINOR_VERSION 7)
3030
set(SYCL_PATCH_VERSION 0)
3131
# Don't forget to re-enable sycl_symbols_windows.dump once we leave ABI-breaking
3232
# window!
33-
set(SYCL_DEV_ABI_VERSION 11)
33+
set(SYCL_DEV_ABI_VERSION 12)
3434
if (SYCL_ADD_DEV_VERSION_POSTFIX)
3535
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
3636
endif()

sycl/include/sycl/accessor.hpp

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ class __SYCL_SPECIAL_CLASS accessor :
10111011
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
10121012
getAdjustedMode(PropertyList),
10131013
detail::getSyclObjImpl(BufferRef).get(), AdjustedDim, sizeof(DataT),
1014-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1014+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
10151015
preScreenAccessor(BufferRef.size(), PropertyList);
10161016
if (!IsPlaceH)
10171017
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1042,7 +1042,7 @@ class __SYCL_SPECIAL_CLASS accessor :
10421042
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
10431043
getAdjustedMode(PropertyList),
10441044
detail::getSyclObjImpl(BufferRef).get(), AdjustedDim, sizeof(DataT),
1045-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1045+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
10461046
preScreenAccessor(BufferRef.size(), PropertyList);
10471047
if (!IsPlaceH)
10481048
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1072,7 +1072,7 @@ class __SYCL_SPECIAL_CLASS accessor :
10721072
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
10731073
getAdjustedMode(PropertyList),
10741074
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1075-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1075+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
10761076
preScreenAccessor(BufferRef.size(), PropertyList);
10771077
detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
10781078
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
@@ -1103,7 +1103,7 @@ class __SYCL_SPECIAL_CLASS accessor :
11031103
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
11041104
getAdjustedMode(PropertyList),
11051105
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1106-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1106+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
11071107
preScreenAccessor(BufferRef.size(), PropertyList);
11081108
detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
11091109
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
@@ -1133,7 +1133,7 @@ class __SYCL_SPECIAL_CLASS accessor :
11331133
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
11341134
getAdjustedMode(PropertyList),
11351135
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1136-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1136+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
11371137
preScreenAccessor(BufferRef.size(), PropertyList);
11381138
if (!IsPlaceH)
11391139
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1166,7 +1166,7 @@ class __SYCL_SPECIAL_CLASS accessor :
11661166
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
11671167
getAdjustedMode(PropertyList),
11681168
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1169-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1169+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
11701170
preScreenAccessor(BufferRef.size(), PropertyList);
11711171
if (!IsPlaceH)
11721172
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1229,7 +1229,7 @@ class __SYCL_SPECIAL_CLASS accessor :
12291229
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
12301230
getAdjustedMode(PropertyList),
12311231
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1232-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1232+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
12331233
preScreenAccessor(BufferRef.size(), PropertyList);
12341234
detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
12351235
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
@@ -1261,7 +1261,7 @@ class __SYCL_SPECIAL_CLASS accessor :
12611261
detail::convertToArrayOfN<3, 1>(BufferRef.get_range()),
12621262
getAdjustedMode(PropertyList),
12631263
detail::getSyclObjImpl(BufferRef).get(), Dimensions, sizeof(DataT),
1264-
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer) {
1264+
BufferRef.OffsetInBytes, BufferRef.IsSubBuffer, PropertyList) {
12651265
preScreenAccessor(BufferRef.size(), PropertyList);
12661266
detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
12671267
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
@@ -1447,7 +1447,7 @@ class __SYCL_SPECIAL_CLASS accessor :
14471447
getAdjustedMode(PropertyList),
14481448
detail::getSyclObjImpl(BufferRef).get(), Dimensions,
14491449
sizeof(DataT), BufferRef.OffsetInBytes,
1450-
BufferRef.IsSubBuffer) {
1450+
BufferRef.IsSubBuffer, PropertyList) {
14511451
preScreenAccessor(BufferRef.size(), PropertyList);
14521452
if (BufferRef.isOutOfBounds(AccessOffset, AccessRange,
14531453
BufferRef.get_range()))
@@ -1488,7 +1488,7 @@ class __SYCL_SPECIAL_CLASS accessor :
14881488
getAdjustedMode(PropertyList),
14891489
detail::getSyclObjImpl(BufferRef).get(), Dimensions,
14901490
sizeof(DataT), BufferRef.OffsetInBytes,
1491-
BufferRef.IsSubBuffer) {
1491+
BufferRef.IsSubBuffer, PropertyList) {
14921492
preScreenAccessor(BufferRef.size(), PropertyList);
14931493
if (BufferRef.isOutOfBounds(AccessOffset, AccessRange,
14941494
BufferRef.get_range()))
@@ -1560,7 +1560,7 @@ class __SYCL_SPECIAL_CLASS accessor :
15601560
getAdjustedMode(PropertyList),
15611561
detail::getSyclObjImpl(BufferRef).get(), Dimensions,
15621562
sizeof(DataT), BufferRef.OffsetInBytes,
1563-
BufferRef.IsSubBuffer) {
1563+
BufferRef.IsSubBuffer, PropertyList) {
15641564
preScreenAccessor(BufferRef.size(), PropertyList);
15651565
if (BufferRef.isOutOfBounds(AccessOffset, AccessRange,
15661566
BufferRef.get_range()))
@@ -1600,7 +1600,7 @@ class __SYCL_SPECIAL_CLASS accessor :
16001600
getAdjustedMode(PropertyList),
16011601
detail::getSyclObjImpl(BufferRef).get(), Dimensions,
16021602
sizeof(DataT), BufferRef.OffsetInBytes,
1603-
BufferRef.IsSubBuffer) {
1603+
BufferRef.IsSubBuffer, PropertyList) {
16041604
preScreenAccessor(BufferRef.size(), PropertyList);
16051605
if (BufferRef.isOutOfBounds(AccessOffset, AccessRange,
16061606
BufferRef.get_range()))
@@ -1785,6 +1785,50 @@ class __SYCL_SPECIAL_CLASS accessor :
17851785
return constant_ptr<DataT>(getPointerAdjusted());
17861786
}
17871787

1788+
// accessor::has_property for runtime properties is only available in host
1789+
// code. This restriction is not listed in the core spec and will be added in
1790+
// future versions.
1791+
template <typename Property>
1792+
typename sycl::detail::enable_if_t<
1793+
!ext::oneapi::is_compile_time_property<Property>::value, bool>
1794+
has_property() const noexcept {
1795+
#ifndef __SYCL_DEVICE_ONLY__
1796+
return AccessorBaseHost::impl->MPropertyList.has_property<Property>();
1797+
#else
1798+
return false;
1799+
#endif
1800+
}
1801+
1802+
// accessor::get_property for runtime properties is only available in host
1803+
// code. This restriction is not listed in the core spec and will be added in
1804+
// future versions.
1805+
template <typename Property,
1806+
typename = typename sycl::detail::enable_if_t<
1807+
!ext::oneapi::is_compile_time_property<Property>::value>>
1808+
Property get_property() const {
1809+
#ifndef __SYCL_DEVICE_ONLY__
1810+
return AccessorBaseHost::impl->MPropertyList.get_property<Property>();
1811+
#else
1812+
return Property();
1813+
#endif
1814+
}
1815+
1816+
#if __cplusplus >= 201703L
1817+
template <typename Property>
1818+
static constexpr bool has_property(
1819+
typename std::enable_if_t<
1820+
ext::oneapi::is_compile_time_property<Property>::value> * = 0) {
1821+
return PropertyListT::template has_property<Property>();
1822+
}
1823+
1824+
template <typename Property>
1825+
static constexpr auto get_property(
1826+
typename std::enable_if_t<
1827+
ext::oneapi::is_compile_time_property<Property>::value> * = 0) {
1828+
return PropertyListT::template get_property<Property>();
1829+
}
1830+
#endif
1831+
17881832
bool operator==(const accessor &Rhs) const { return impl == Rhs.impl; }
17891833
bool operator!=(const accessor &Rhs) const { return !(*this == Rhs); }
17901834

sycl/include/sycl/detail/accessor_impl.hpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <sycl/access/access.hpp>
1212
#include <sycl/detail/export.hpp>
1313
#include <sycl/id.hpp>
14+
#include <sycl/property_list.hpp>
1415
#include <sycl/range.hpp>
1516
#include <sycl/stl.hpp>
1617

@@ -80,12 +81,14 @@ class __SYCL_EXPORT AccessorImplHost {
8081
AccessorImplHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange,
8182
access::mode AccessMode, void *SYCLMemObject, int Dims,
8283
int ElemSize, int OffsetInBytes = 0,
83-
bool IsSubBuffer = false, bool IsESIMDAcc = false)
84+
bool IsSubBuffer = false, bool IsESIMDAcc = false,
85+
const property_list &PropertyList = {})
8486
: MOffset(Offset), MAccessRange(AccessRange), MMemoryRange(MemoryRange),
8587
MAccessMode(AccessMode),
8688
MSYCLMemObj((detail::SYCLMemObjI *)SYCLMemObject), MDims(Dims),
8789
MElemSize(ElemSize), MOffsetInBytes(OffsetInBytes),
88-
MIsSubBuffer(IsSubBuffer), MIsESIMDAcc(IsESIMDAcc) {}
90+
MIsSubBuffer(IsSubBuffer), MIsESIMDAcc(IsESIMDAcc),
91+
MPropertyList(PropertyList) {}
8992

9093
~AccessorImplHost();
9194

@@ -130,20 +133,27 @@ class __SYCL_EXPORT AccessorImplHost {
130133
// Outdated, leaving to preserve ABI.
131134
// TODO: Remove during next major release.
132135
bool MIsESIMDAcc;
136+
137+
// To preserve runtime properties
138+
property_list MPropertyList;
133139
};
134140

135141
using AccessorImplPtr = std::shared_ptr<AccessorImplHost>;
136142

137143
class AccessorBaseHost {
138144
public:
145+
template <typename PropertyListT = property_list>
139146
AccessorBaseHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange,
140147
access::mode AccessMode, void *SYCLMemObject, int Dims,
141148
int ElemSize, int OffsetInBytes = 0,
142-
bool IsSubBuffer = false) {
149+
bool IsSubBuffer = false,
150+
const PropertyListT &PropertyList = {}) {
143151
impl = std::shared_ptr<AccessorImplHost>(
144152
new AccessorImplHost(Offset, AccessRange, MemoryRange, AccessMode,
145153
(detail::SYCLMemObjI *)SYCLMemObject, Dims,
146-
ElemSize, OffsetInBytes, IsSubBuffer));
154+
ElemSize, OffsetInBytes, IsSubBuffer,
155+
/* IsESIMDAcc = */ false,
156+
PropertyList));
147157
}
148158

149159
protected:

sycl/include/sycl/ext/oneapi/accessor_property_list.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ class accessor_property_list : protected sycl::detail::PropertyListBase {
212212
}
213213
#endif
214214

215+
operator sycl::property_list() const {
216+
return property_list(MDataLessProps, MPropsWithData);
217+
}
218+
215219
private:
216220
template <typename, int, access::mode, access::target, access::placeholder,
217221
typename PropertyListT>

sycl/include/sycl/property_list.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ class property_list : protected detail::PropertyListBase {
6161
template <typename... T> operator ext::oneapi::accessor_property_list<T...>();
6262

6363
private:
64+
property_list(
65+
std::bitset<detail::DataLessPropKind::DataLessPropKindSize> DataLessProps,
66+
std::vector<std::shared_ptr<detail::PropertyWithDataBase>> PropsWithData)
67+
: sycl::detail::PropertyListBase(DataLessProps, PropsWithData) {}
68+
6469
template <typename... PropsT>
6570
friend class ext::oneapi::accessor_property_list;
6671
};

sycl/test/abi/layout_accessors_host.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,22 @@ using namespace sycl;
2828
// CHECK-NEXT: 112 | Command * MBlockedCmd
2929
// CHECK-NEXT: 120 | _Bool PerWI
3030
// CHECK-NEXT: 121 | _Bool MIsESIMDAcc
31-
// CHECK-NEXT: | [sizeof=128, dsize=122, align=8,
32-
// CHECK-NEXT: | nvsize=122, nvalign=8]
31+
// CHECK-NEXT: 128 | class sycl::property_list MPropertyList
32+
// CHECK-NEXT: 128 | class sycl::detail::PropertyListBase (base)
33+
// CHECK-NEXT: 128 | class std::bitset<32> MDataLessProps
34+
// CHECK-NEXT: 128 | struct std::_Base_bitset<1> (base)
35+
// CHECK-NEXT: 128 | _WordT _M_w
36+
// CHECK-NEXT: 136 | class std::vector<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > MPropsWithData
37+
// CHECK-NEXT: 136 | struct std::_Vector_base<class std::shared_ptr<class sycl::detail::PropertyWithDataBase>, class std::allocator<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > > (base)
38+
// CHECK-NEXT: 136 | struct std::_Vector_base<class std::shared_ptr<class sycl::detail::PropertyWithDataBase>, class std::allocator<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > >::_Vector_impl _M_impl
39+
// CHECK-NEXT: 136 | class std::allocator<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > (base) (empty)
40+
// CHECK-NEXT: 136 | class __gnu_cxx::new_allocator<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > (base) (empty)
41+
// CHECK-NEXT: 136 | struct std::_Vector_base<class std::shared_ptr<class sycl::detail::PropertyWithDataBase>, class std::allocator<class std::shared_ptr<class sycl::detail::PropertyWithDataBase> > >::_Vector_impl_data (base)
42+
// CHECK-NEXT: 136 | pointer _M_start
43+
// CHECK-NEXT: 144 | pointer _M_finish
44+
// CHECK-NEXT: 152 | pointer _M_end_of_storage
45+
// CHECK-NEXT: | [sizeof=160, dsize=160, align=8,
46+
// CHECK-NEXT: | nvsize=160, nvalign=8]
3347

3448
// CHECK: 0 | class sycl::detail::LocalAccessorImplHost
3549
// CHECK-NEXT: 0 | class sycl::range<3> MSize

sycl/test/abi/symbol_size_alignment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main() {
4444
check<accessor_t, 32, 8>();
4545
check<detail::AccessorImplDevice<1>, 24, 8>();
4646
check<detail::LocalAccessorBaseDevice<1>, 24, 8>();
47-
check<detail::AccessorImplHost, 128, 8>();
47+
check<detail::AccessorImplHost, 160, 8>();
4848
check<detail::AccessorBaseHost, 16, 8>();
4949
check<detail::LocalAccessorImplHost, 56, 8>();
5050
check<buffer<int>, 40, 8>();

0 commit comments

Comments
 (0)