Skip to content

Commit 1136b40

Browse files
authored
[SYCL][ABI-Break] Implement property interface for local_accessor & usm_allocator (intel#6737)
1 parent 72c9762 commit 1136b40

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ set(SYCL_MINOR_VERSION 7)
3232
set(SYCL_PATCH_VERSION 0)
3333
# Don't forget to re-enable sycl_symbols_windows.dump once we leave ABI-breaking
3434
# window!
35-
set(SYCL_DEV_ABI_VERSION 17)
35+
set(SYCL_DEV_ABI_VERSION 18)
3636
if (SYCL_ADD_DEV_VERSION_POSTFIX)
3737
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
3838
endif()

sycl/include/sycl/accessor.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,15 @@ using LocalAccessorImplPtr = std::shared_ptr<LocalAccessorImplHost>;
496496

497497
class __SYCL_EXPORT LocalAccessorBaseHost {
498498
public:
499-
LocalAccessorBaseHost(sycl::range<3> Size, int Dims, int ElemSize);
499+
LocalAccessorBaseHost(sycl::range<3> Size, int Dims, int ElemSize,
500+
const property_list &PropertyList = {});
500501
sycl::range<3> &getSize();
501502
const sycl::range<3> &getSize() const;
502503
void *getPtr();
503504
void *getPtr() const;
504505
int getNumOfDims();
505506
int getElementSize();
507+
const property_list &getPropList() const;
506508

507509
protected:
508510
template <class Obj>
@@ -2366,8 +2368,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
23662368
(void)propList;
23672369
}
23682370
#else
2369-
: LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT)) {
2370-
(void)propList;
2371+
: LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT),
2372+
propList) {
23712373
detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(),
23722374
access::target::local, AccessMode, CodeLoc);
23732375
GDBMethodsAnchor();
@@ -2401,8 +2403,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
24012403
}
24022404
#else
24032405
: LocalAccessorBaseHost(detail::convertToArrayOfN<3, 1>(AllocationSize),
2404-
AdjustedDim, sizeof(DataT)) {
2405-
(void)propList;
2406+
AdjustedDim, sizeof(DataT), propList) {
24062407
detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(),
24072408
access::target::local, AccessMode, CodeLoc);
24082409
GDBMethodsAnchor();
@@ -2547,6 +2548,23 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
25472548
}
25482549

25492550
#endif
2551+
2552+
public:
2553+
template <typename Property> bool has_property() const noexcept {
2554+
#ifndef __SYCL_DEVICE_ONLY__
2555+
return this->getPropList().template has_property<Property>();
2556+
#else
2557+
return false;
2558+
#endif
2559+
}
2560+
2561+
template <typename Property> Property get_property() const {
2562+
#ifndef __SYCL_DEVICE_ONLY__
2563+
return this->getPropList().template get_property<Property>();
2564+
#else
2565+
return Property();
2566+
#endif
2567+
}
25502568
};
25512569

25522570
/// Image accessors.

sycl/include/sycl/usm/usm_allocator.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ class usm_allocator {
106106
(One.MDevice == Two.MDevice));
107107
}
108108

109+
template <typename Property> bool has_property() const noexcept {
110+
return MPropList.has_property<Property>();
111+
}
112+
113+
template <typename Property> Property get_property() const {
114+
return MPropList.get_property<Property>();
115+
}
116+
109117
private:
110118
constexpr size_t getAlignment() const { return max(alignof(T), Alignment); }
111119

sycl/source/accessor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ void *AccessorBaseHost::getPtr() const {
5252

5353
void *AccessorBaseHost::getMemoryObject() const { return impl->MSYCLMemObj; }
5454

55-
LocalAccessorBaseHost::LocalAccessorBaseHost(sycl::range<3> Size, int Dims,
56-
int ElemSize) {
55+
LocalAccessorBaseHost::LocalAccessorBaseHost(
56+
sycl::range<3> Size, int Dims, int ElemSize,
57+
const property_list &PropertyList) {
5758
impl = std::shared_ptr<LocalAccessorImplHost>(
58-
new LocalAccessorImplHost(Size, Dims, ElemSize));
59+
new LocalAccessorImplHost(Size, Dims, ElemSize, PropertyList));
5960
}
6061
sycl::range<3> &LocalAccessorBaseHost::getSize() { return impl->MSize; }
6162
const sycl::range<3> &LocalAccessorBaseHost::getSize() const {
@@ -76,6 +77,9 @@ void *LocalAccessorBaseHost::getPtr() const {
7677

7778
return ptr;
7879
}
80+
const property_list &LocalAccessorBaseHost::getPropList() const {
81+
return impl->MPropertyList;
82+
}
7983

8084
int LocalAccessorBaseHost::getNumOfDims() { return impl->MDims; }
8185
int LocalAccessorBaseHost::getElementSize() { return impl->MElemSize; }

sycl/source/detail/accessor_impl.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,17 @@ class __SYCL_EXPORT LocalAccessorImplHost {
101101
public:
102102
// Allocate ElemSize more data to have sufficient padding to enforce
103103
// alignment.
104-
LocalAccessorImplHost(sycl::range<3> Size, int Dims, int ElemSize)
104+
LocalAccessorImplHost(sycl::range<3> Size, int Dims, int ElemSize,
105+
const property_list &PropertyList)
105106
: MSize(Size), MDims(Dims), MElemSize(ElemSize),
106-
MMem(Size[0] * Size[1] * Size[2] * ElemSize + ElemSize) {}
107+
MMem(Size[0] * Size[1] * Size[2] * ElemSize + ElemSize),
108+
MPropertyList(PropertyList) {}
107109

108110
sycl::range<3> MSize;
109111
int MDims;
110112
int MElemSize;
111113
std::vector<char> MMem;
114+
property_list MPropertyList;
112115
};
113116

114117
using LocalAccessorImplPtr = std::shared_ptr<LocalAccessorImplHost>;

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,8 +3843,8 @@ _ZN4sycl3_V16detail21LocalAccessorBaseHost12getNumOfDimsEv
38433843
_ZN4sycl3_V16detail21LocalAccessorBaseHost14getElementSizeEv
38443844
_ZN4sycl3_V16detail21LocalAccessorBaseHost6getPtrEv
38453845
_ZN4sycl3_V16detail21LocalAccessorBaseHost7getSizeEv
3846-
_ZN4sycl3_V16detail21LocalAccessorBaseHostC1ENS0_5rangeILi3EEEii
3847-
_ZN4sycl3_V16detail21LocalAccessorBaseHostC2ENS0_5rangeILi3EEEii
3846+
_ZN4sycl3_V16detail21LocalAccessorBaseHostC1ENS0_5rangeILi3EEEiiRKNS0_13property_listE
3847+
_ZN4sycl3_V16detail21LocalAccessorBaseHostC2ENS0_5rangeILi3EEEiiRKNS0_13property_listE
38483848
_ZN4sycl3_V16detail22addHostAccessorAndWaitEPNS1_16AccessorImplHostE
38493849
_ZN4sycl3_V16detail22getImageNumberChannelsENS0_19image_channel_orderE
38503850
_ZN4sycl3_V16detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE
@@ -4136,6 +4136,7 @@ _ZNK4sycl3_V16detail19kernel_bundle_plain33contains_specialization_constantsEv
41364136
_ZNK4sycl3_V16detail19kernel_bundle_plain3endEv
41374137
_ZNK4sycl3_V16detail19kernel_bundle_plain5beginEv
41384138
_ZNK4sycl3_V16detail19kernel_bundle_plain5emptyEv
4139+
_ZNK4sycl3_V16detail21LocalAccessorBaseHost11getPropListEv
41394140
_ZNK4sycl3_V16detail21LocalAccessorBaseHost6getPtrEv
41404141
_ZNK4sycl3_V16detail21LocalAccessorBaseHost7getSizeEv
41414142
_ZNK4sycl3_V16device11get_backendEv

0 commit comments

Comments
 (0)