Skip to content

[SYCL] Ignore placeholder template parameter for accessor #8071

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
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
124 changes: 72 additions & 52 deletions sycl/include/sycl/accessor.hpp

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion sycl/source/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@ AccessorBaseHost::AccessorBaseHost(id<3> Offset, range<3> AccessRange,
impl = std::shared_ptr<AccessorImplHost>(
new AccessorImplHost(Offset, AccessRange, MemoryRange, AccessMode,
(detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize,
OffsetInBytes, IsSubBuffer, PropertyList));
false, OffsetInBytes, IsSubBuffer, PropertyList));
}

AccessorBaseHost::AccessorBaseHost(id<3> Offset, range<3> AccessRange,
range<3> MemoryRange,
access::mode AccessMode, void *SYCLMemObject,
int Dims, int ElemSize, bool IsPlaceH,
int OffsetInBytes, bool IsSubBuffer,
const property_list &PropertyList) {
impl = std::shared_ptr<AccessorImplHost>(
new AccessorImplHost(Offset, AccessRange, MemoryRange, AccessMode,
(detail::SYCLMemObjI *)SYCLMemObject, Dims, ElemSize,
IsPlaceH, OffsetInBytes, IsSubBuffer, PropertyList));
}

id<3> &AccessorBaseHost::getOffset() { return impl->MOffset; }
Expand Down Expand Up @@ -54,6 +66,8 @@ void *AccessorBaseHost::getPtr() const {

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

bool AccessorBaseHost::isPlaceholder() const { return impl->MIsPlaceH; }

LocalAccessorBaseHost::LocalAccessorBaseHost(
sycl::range<3> Size, int Dims, int ElemSize,
const property_list &PropertyList) {
Expand Down
22 changes: 20 additions & 2 deletions sycl/source/detail/accessor_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Command;

class __SYCL_EXPORT AccessorImplHost {
public:
// TODO: Remove when ABI break is allowed.
AccessorImplHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange,
access::mode AccessMode, void *SYCLMemObject, int Dims,
int ElemSize, int OffsetInBytes = 0,
Expand All @@ -49,15 +50,28 @@ class __SYCL_EXPORT AccessorImplHost {
: MAccData(Offset, AccessRange, MemoryRange), MAccessMode(AccessMode),
MSYCLMemObj((detail::SYCLMemObjI *)SYCLMemObject), MDims(Dims),
MElemSize(ElemSize), MOffsetInBytes(OffsetInBytes),
MIsSubBuffer(IsSubBuffer), MPropertyList(PropertyList) {}
MIsSubBuffer(IsSubBuffer), MPropertyList(PropertyList),
MIsPlaceH(false) {}

AccessorImplHost(id<3> Offset, range<3> AccessRange, range<3> MemoryRange,
access::mode AccessMode, void *SYCLMemObject, int Dims,
int ElemSize, bool IsPlaceH, int OffsetInBytes = 0,
bool IsSubBuffer = false,
const property_list &PropertyList = {})
: MAccData(Offset, AccessRange, MemoryRange), MAccessMode(AccessMode),
MSYCLMemObj((detail::SYCLMemObjI *)SYCLMemObject), MDims(Dims),
MElemSize(ElemSize), MOffsetInBytes(OffsetInBytes),
MIsSubBuffer(IsSubBuffer), MPropertyList(PropertyList),
MIsPlaceH(IsPlaceH) {}

~AccessorImplHost();

AccessorImplHost(const AccessorImplHost &Other)
: MAccData(Other.MAccData), MAccessMode(Other.MAccessMode),
MSYCLMemObj(Other.MSYCLMemObj), MDims(Other.MDims),
MElemSize(Other.MElemSize), MOffsetInBytes(Other.MOffsetInBytes),
MIsSubBuffer(Other.MIsSubBuffer), MPropertyList(Other.MPropertyList) {}
MIsSubBuffer(Other.MIsSubBuffer), MPropertyList(Other.MPropertyList),
MIsPlaceH(Other.MIsPlaceH) {}

AccessorImplHost &operator=(const AccessorImplHost &Other) {
MAccData = Other.MAccData;
Expand All @@ -68,6 +82,7 @@ class __SYCL_EXPORT AccessorImplHost {
MOffsetInBytes = Other.MOffsetInBytes;
MIsSubBuffer = Other.MIsSubBuffer;
MPropertyList = Other.MPropertyList;
MIsPlaceH = Other.MIsPlaceH;
return *this;
}

Expand Down Expand Up @@ -106,6 +121,9 @@ class __SYCL_EXPORT AccessorImplHost {

// To preserve runtime properties
property_list MPropertyList;

// Placeholder flag
bool MIsPlaceH;
};

using AccessorImplPtr = std::shared_ptr<AccessorImplHost>;
Expand Down
3 changes: 3 additions & 0 deletions sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3836,7 +3836,9 @@ _ZN4sycl3_V16detail16AccessorBaseHost14getAccessRangeEv
_ZN4sycl3_V16detail16AccessorBaseHost14getMemoryRangeEv
_ZN4sycl3_V16detail16AccessorBaseHost6getPtrEv
_ZN4sycl3_V16detail16AccessorBaseHost9getOffsetEv
_ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviibibRKNS0_13property_listE
_ZN4sycl3_V16detail16AccessorBaseHostC1ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviiibRKNS0_13property_listE
_ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviibibRKNS0_13property_listE
_ZN4sycl3_V16detail16AccessorBaseHostC2ENS0_2idILi3EEENS0_5rangeILi3EEES6_NS0_6access4modeEPviiibRKNS0_13property_listE
_ZN4sycl3_V16detail16AccessorImplHost6resizeEm
_ZN4sycl3_V16detail16AccessorImplHostD1Ev
Expand Down Expand Up @@ -4174,6 +4176,7 @@ _ZNK4sycl3_V16detail12sampler_impl19get_addressing_modeEv
_ZNK4sycl3_V16detail12sampler_impl33get_coordinate_normalization_modeEv
_ZNK4sycl3_V16detail16AccessorBaseHost11getElemSizeEv
_ZNK4sycl3_V16detail16AccessorBaseHost11getPropListEv
_ZNK4sycl3_V16detail16AccessorBaseHost13isPlaceholderEv
_ZNK4sycl3_V16detail16AccessorBaseHost14getAccessRangeEv
_ZNK4sycl3_V16detail16AccessorBaseHost14getMemoryRangeEv
_ZNK4sycl3_V16detail16AccessorBaseHost15getMemoryObjectEv
Expand Down
5 changes: 4 additions & 1 deletion sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# DO NOT EDIT IT MANUALLY. Refer to sycl/doc/developer/ABIPolicyGuide.md for more info.
################################################################################

# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %llvm_build_bin_dir/sycl6.dll
# RUN: env LLVM_BIN_PATH=%llvm_build_bin_dir %python %sycl_tools_src_dir/abi_check.py --mode check_symbols --reference %s %llvm_build_bin_dir/sycl6.dll
# REQUIRES: windows
# UNSUPPORTED: libcxx

Expand Down Expand Up @@ -359,8 +359,10 @@
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@$$QEAV0123@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHHH_NAEBVproperty_list@23@@Z
??0AccessorBaseHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHH_NH4AEBVproperty_list@23@@Z
??0AccessorImplHost@detail@_V1@sycl@@QEAA@AEBV0123@@Z
??0AccessorImplHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHHH_NAEBVproperty_list@23@@Z
??0AccessorImplHost@detail@_V1@sycl@@QEAA@V?$id@$02@23@V?$range@$02@23@1W4mode@access@23@PEAXHH_NH4AEBVproperty_list@23@@Z
??0HostProfilingInfo@detail@_V1@sycl@@QEAA@XZ
??0LocalAccessorBaseHost@detail@_V1@sycl@@IEAA@AEBV?$shared_ptr@VLocalAccessorImplHost@detail@_V1@sycl@@@std@@@Z
??0LocalAccessorBaseHost@detail@_V1@sycl@@QEAA@$$QEAV0123@@Z
Expand Down Expand Up @@ -1038,6 +1040,7 @@
?isInterop@SYCLMemObjT@detail@_V1@sycl@@QEBA_NXZ
?isOutOfRange@detail@_V1@sycl@@YA_NV?$vec@H$03@23@W4addressing_mode@23@V?$range@$02@23@@Z
?isPathPresent@OSUtil@detail@_V1@sycl@@SA_NAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z
?isPlaceholder@AccessorBaseHost@detail@_V1@sycl@@QEBA_NXZ
?isStateExplicitKernelBundle@handler@_V1@sycl@@AEBA_NXZ
?isValidModeForDestinationAccessor@handler@_V1@sycl@@CA_NW4mode@access@23@@Z
?isValidModeForSourceAccessor@handler@_V1@sycl@@CA_NW4mode@access@23@@Z
Expand Down
136 changes: 136 additions & 0 deletions sycl/unittests/accessor/AccessorPlaceholder.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
#include <gtest/gtest.h>

#include <helpers/PiImage.hpp>
#include <helpers/PiMock.hpp>
#include <numeric>
#include <sycl/sycl.hpp>

TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderNoneTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
using AccT = sycl::accessor<int, 1, acmode, actarget>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_TRUE(acc.is_placeholder());
}

TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderTrueTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::true_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_TRUE(acc.is_placeholder());
}

TEST(AccessorPlaceholderTest, NoCommandGroupPlaceholderFalseTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::false_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_TRUE(acc.is_placeholder());
}

TEST(AccessorPlaceholderTest, PlaceholderNoneTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
using AccT = sycl::accessor<int, 1, acmode, actarget>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
sycl::unittest::PiMock Mock;
sycl::platform Plt = Mock.getPlatform();
sycl::queue q{Plt.get_devices()[0]};
q.submit([&](sycl::handler &cgh) {
AccT acc(data_buf, cgh);
EXPECT_FALSE(acc.is_placeholder());
});
}

TEST(AccessorPlaceholderTest, PlaceholderTrueTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::true_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
sycl::unittest::PiMock Mock;
sycl::platform Plt = Mock.getPlatform();
sycl::queue q{Plt.get_devices()[0]};
q.submit([&](sycl::handler &cgh) {
AccT acc(data_buf, cgh);
EXPECT_FALSE(acc.is_placeholder());
});
}

TEST(AccessorPlaceholderTest, PlaceholderFalseTargetDevice) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget = sycl::access::target::device;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::false_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
sycl::unittest::PiMock Mock;
sycl::platform Plt = Mock.getPlatform();
sycl::queue q{Plt.get_devices()[0]};
q.submit([&](sycl::handler &cgh) {
AccT acc(data_buf, cgh);
EXPECT_FALSE(acc.is_placeholder());
});
}

TEST(AccessorPlaceholderTest, PlaceholderNoneTargetHost) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget =
sycl::access::target::host_buffer;
using AccT = sycl::accessor<int, 1, acmode, actarget>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_FALSE(acc.is_placeholder());
EXPECT_EQ(acc[0], data);
}

TEST(AccessorPlaceholderTest, PlaceholderTrueTargetHost) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget =
sycl::access::target::host_buffer;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::true_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_FALSE(acc.is_placeholder());
}

TEST(AccessorPlaceholderTest, PlaceholderFalseTargetHost) {
static constexpr sycl::access_mode acmode = sycl::access_mode::read;
static constexpr sycl::access::target actarget =
sycl::access::target::host_buffer;
static constexpr sycl::access::placeholder acplaceholder =
sycl::access::placeholder::false_t;
using AccT = sycl::accessor<int, 1, acmode, actarget, acplaceholder>;
int data(14);
sycl::range<1> r(1);
sycl::buffer<int, 1> data_buf(&data, r);
AccT acc(data_buf);
EXPECT_FALSE(acc.is_placeholder());
}
1 change: 1 addition & 0 deletions sycl/unittests/accessor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
add_sycl_unittest(AccessorTests OBJECT
AccessorIterator.cpp
AccessorPlaceholder.cpp
AccessorReverseIterator.cpp
HostAccessorIterator.cpp
HostAccessorReverseIterator.cpp
Expand Down