Skip to content

Commit fb72758

Browse files
bso-intelkeryell
andauthored
[SYCL] Fix buffer constructor using iterators (#1386)
Fixed the buffer constructor called with a pair of iterators. The current implementation has a problem due to ambiguous spec. The buffer should never write back data unless there is a call to set_final_data(), but the current implementation does it. I corrected the spec in KhronosGroup/SYCL-Docs#76. So, now we can change the buffer implementation according to the clarified spec. The test case buffer.cpp also needed change because of this change. The user should not expect the automatic write-back of data upon destruction of buffer. Signed-off-by: Byoungro So <byoungro.so@intel.com> Co-authored-by: Ronan Keryell <ronan@keryell.fr>
1 parent a5b9804 commit fb72758

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ class buffer_impl final : public SYCLMemObjT {
8181
unique_ptr_class<SYCLMemObjAllocator> Allocator)
8282
: BaseT(SizeInBytes, Props, std::move(Allocator)) {
8383
BaseT::handleHostData(First, Last, RequiredAlign);
84-
// TODO: There is contradiction in the spec, in one place it says
85-
// the data is not copied back at all if the buffer is construted
86-
// using this c'tor, another section says that the data will be
87-
// copied back if iterators passed are not const ( 4.7.2.3 Buffer
88-
// Synchronization Rules and this constructor description)
89-
BaseT::set_final_data(First);
9084
}
9185

9286
template <typename T>

sycl/test/basic_tests/buffer/buffer.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,9 @@ int main() {
436436
range<1>{3}, [=](id<1> index) { B[index] = 20; });
437437
});
438438
}
439-
// Data is copied back in the desctruction of the buffer created from
440-
// pair of non-const iterators
441-
for (int i = 0; i < 2; i++)
442-
assert(data1[i] == -1);
443-
for (int i = 2; i < 5; i++)
444-
assert(data1[i] == 20);
445-
for (int i = 5; i < 10; i++)
439+
// Data is not copied back in the destruction of the buffer created
440+
// from a pair of non-const iterators
441+
for (int i = 0; i < 10; i++)
446442
assert(data1[i] == -1);
447443
}
448444

0 commit comments

Comments
 (0)