Skip to content

[SYCL] Fixed sub-buffer alloca search #1385

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 1 commit into from
Mar 25, 2020
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
3 changes: 0 additions & 3 deletions sycl/source/detail/scheduler/graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
if (AllocaCmdDst->getType() == Command::CommandType::ALLOCA_SUB_BUF)
AllocaCmdDst =
static_cast<AllocaSubBufCommand *>(AllocaCmdDst)->getParentAlloca();
else
assert(
!"Inappropriate alloca command. AllocaSubBufCommand was expected.");
}

AllocaCommandBase *AllocaCmdSrc =
Expand Down
14 changes: 14 additions & 0 deletions sycl/test/basic_tests/buffer/subbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,20 @@ void checkMultipleContexts() {
});
}
assert(a[N / 2 - 1] == 1 && a[N / 2] == 2 && "Sub buffer data loss");

{
sycl::queue queue1;
sycl::buffer<int, 1> buf(a, sycl::range<1>(N));
sycl::buffer<int, 1> subbuf1(buf, sycl::id<1>(0), sycl::range<1>(N / 2));
queue1.submit([&](sycl::handler &cgh) {
auto bufacc = subbuf1.get_access<sycl::access::mode::read_write>(cgh);
cgh.parallel_for<class sub_buffer_3>(
sycl::range<1>(N / 2), [=](sycl::id<1> idx) { bufacc[idx[0]] = -1; });
});
auto host_acc = subbuf1.get_access<sycl::access::mode::read>();
assert(host_acc[0] == -1 && host_acc[N / 2 - 1] == -1 &&
"Sub buffer data loss");
}
}

int main() {
Expand Down