Skip to content

[SYCL][ABI-Break] Implement property interface for local_accessor & #6737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ set(SYCL_MINOR_VERSION 7)
set(SYCL_PATCH_VERSION 0)
# Don't forget to re-enable sycl_symbols_windows.dump once we leave ABI-breaking
# window!
set(SYCL_DEV_ABI_VERSION 17)
set(SYCL_DEV_ABI_VERSION 18)
if (SYCL_ADD_DEV_VERSION_POSTFIX)
set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}")
endif()
Expand Down
28 changes: 23 additions & 5 deletions sycl/include/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,15 @@ using LocalAccessorImplPtr = std::shared_ptr<LocalAccessorImplHost>;

class __SYCL_EXPORT LocalAccessorBaseHost {
public:
LocalAccessorBaseHost(sycl::range<3> Size, int Dims, int ElemSize);
LocalAccessorBaseHost(sycl::range<3> Size, int Dims, int ElemSize,
const property_list &PropertyList = {});
sycl::range<3> &getSize();
const sycl::range<3> &getSize() const;
void *getPtr();
void *getPtr() const;
int getNumOfDims();
int getElementSize();
const property_list &getPropList() const;

protected:
template <class Obj>
Expand Down Expand Up @@ -2366,8 +2368,8 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
(void)propList;
}
#else
: LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT)) {
(void)propList;
: LocalAccessorBaseHost(range<3>{1, 1, 1}, AdjustedDim, sizeof(DataT),
propList) {
detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(),
access::target::local, AccessMode, CodeLoc);
GDBMethodsAnchor();
Expand Down Expand Up @@ -2401,8 +2403,7 @@ class __SYCL_SPECIAL_CLASS local_accessor_base :
}
#else
: LocalAccessorBaseHost(detail::convertToArrayOfN<3, 1>(AllocationSize),
AdjustedDim, sizeof(DataT)) {
(void)propList;
AdjustedDim, sizeof(DataT), propList) {
detail::constructorNotification(nullptr, LocalAccessorBaseHost::impl.get(),
access::target::local, AccessMode, CodeLoc);
GDBMethodsAnchor();
Expand Down Expand Up @@ -2547,6 +2548,23 @@ class __SYCL_SPECIAL_CLASS __SYCL_TYPE(local_accessor) local_accessor
}

#endif

public:
template <typename Property> bool has_property() const noexcept {
#ifndef __SYCL_DEVICE_ONLY__
return this->getPropList().template has_property<Property>();
#else
return false;
#endif
}

template <typename Property> Property get_property() const {
#ifndef __SYCL_DEVICE_ONLY__
return this->getPropList().template get_property<Property>();
#else
return Property();
#endif
}
};

/// Image accessors.
Expand Down
8 changes: 8 additions & 0 deletions sycl/include/sycl/usm/usm_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ class usm_allocator {
(One.MDevice == Two.MDevice));
}

template <typename Property> bool has_property() const noexcept {
return MPropList.has_property<Property>();
}

template <typename Property> Property get_property() const {
return MPropList.get_property<Property>();
}

private:
constexpr size_t getAlignment() const { return max(alignof(T), Alignment); }

Expand Down
10 changes: 7 additions & 3 deletions sycl/source/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ void *AccessorBaseHost::getPtr() const {

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

LocalAccessorBaseHost::LocalAccessorBaseHost(sycl::range<3> Size, int Dims,
int ElemSize) {
LocalAccessorBaseHost::LocalAccessorBaseHost(
sycl::range<3> Size, int Dims, int ElemSize,
const property_list &PropertyList) {
impl = std::shared_ptr<LocalAccessorImplHost>(
new LocalAccessorImplHost(Size, Dims, ElemSize));
new LocalAccessorImplHost(Size, Dims, ElemSize, PropertyList));
}
sycl::range<3> &LocalAccessorBaseHost::getSize() { return impl->MSize; }
const sycl::range<3> &LocalAccessorBaseHost::getSize() const {
Expand All @@ -76,6 +77,9 @@ void *LocalAccessorBaseHost::getPtr() const {

return ptr;
}
const property_list &LocalAccessorBaseHost::getPropList() const {
return impl->MPropertyList;
}

int LocalAccessorBaseHost::getNumOfDims() { return impl->MDims; }
int LocalAccessorBaseHost::getElementSize() { return impl->MElemSize; }
Expand Down
7 changes: 5 additions & 2 deletions sycl/source/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,17 @@ class __SYCL_EXPORT LocalAccessorImplHost {
public:
// Allocate ElemSize more data to have sufficient padding to enforce
// alignment.
LocalAccessorImplHost(sycl::range<3> Size, int Dims, int ElemSize)
LocalAccessorImplHost(sycl::range<3> Size, int Dims, int ElemSize,
const property_list &PropertyList)
: MSize(Size), MDims(Dims), MElemSize(ElemSize),
MMem(Size[0] * Size[1] * Size[2] * ElemSize + ElemSize) {}
MMem(Size[0] * Size[1] * Size[2] * ElemSize + ElemSize),
MPropertyList(PropertyList) {}

sycl::range<3> MSize;
int MDims;
int MElemSize;
std::vector<char> MMem;
property_list MPropertyList;
};

using LocalAccessorImplPtr = std::shared_ptr<LocalAccessorImplHost>;
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3843,8 +3843,8 @@ _ZN4sycl3_V16detail21LocalAccessorBaseHost12getNumOfDimsEv
_ZN4sycl3_V16detail21LocalAccessorBaseHost14getElementSizeEv
_ZN4sycl3_V16detail21LocalAccessorBaseHost6getPtrEv
_ZN4sycl3_V16detail21LocalAccessorBaseHost7getSizeEv
_ZN4sycl3_V16detail21LocalAccessorBaseHostC1ENS0_5rangeILi3EEEii
_ZN4sycl3_V16detail21LocalAccessorBaseHostC2ENS0_5rangeILi3EEEii
_ZN4sycl3_V16detail21LocalAccessorBaseHostC1ENS0_5rangeILi3EEEiiRKNS0_13property_listE
_ZN4sycl3_V16detail21LocalAccessorBaseHostC2ENS0_5rangeILi3EEEiiRKNS0_13property_listE
_ZN4sycl3_V16detail22addHostAccessorAndWaitEPNS1_16AccessorImplHostE
_ZN4sycl3_V16detail22getImageNumberChannelsENS0_19image_channel_orderE
_ZN4sycl3_V16detail22get_kernel_bundle_implERKNS0_7contextERKSt6vectorINS0_6deviceESaIS6_EENS0_12bundle_stateE
Expand Down Expand Up @@ -4136,6 +4136,7 @@ _ZNK4sycl3_V16detail19kernel_bundle_plain33contains_specialization_constantsEv
_ZNK4sycl3_V16detail19kernel_bundle_plain3endEv
_ZNK4sycl3_V16detail19kernel_bundle_plain5beginEv
_ZNK4sycl3_V16detail19kernel_bundle_plain5emptyEv
_ZNK4sycl3_V16detail21LocalAccessorBaseHost11getPropListEv
_ZNK4sycl3_V16detail21LocalAccessorBaseHost6getPtrEv
_ZNK4sycl3_V16detail21LocalAccessorBaseHost7getSizeEv
_ZNK4sycl3_V16device11get_backendEv
Expand Down