Skip to content

Commit 5d1d716

Browse files
author
Ivan Karachun
authored
[SYCL] Fixed sub-buffer alloca search (#1385)
If found alloca command is not sub-buffer alloca, then it's parent alloca which has same context Signed-off-by: Ivan Karachun <[email protected]>
1 parent b01e868 commit 5d1d716

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

sycl/source/detail/scheduler/graph_builder.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,6 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record,
240240
if (AllocaCmdDst->getType() == Command::CommandType::ALLOCA_SUB_BUF)
241241
AllocaCmdDst =
242242
static_cast<AllocaSubBufCommand *>(AllocaCmdDst)->getParentAlloca();
243-
else
244-
assert(
245-
!"Inappropriate alloca command. AllocaSubBufCommand was expected.");
246243
}
247244

248245
AllocaCommandBase *AllocaCmdSrc =

sycl/test/basic_tests/buffer/subbuffer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,20 @@ void checkMultipleContexts() {
275275
});
276276
}
277277
assert(a[N / 2 - 1] == 1 && a[N / 2] == 2 && "Sub buffer data loss");
278+
279+
{
280+
sycl::queue queue1;
281+
sycl::buffer<int, 1> buf(a, sycl::range<1>(N));
282+
sycl::buffer<int, 1> subbuf1(buf, sycl::id<1>(0), sycl::range<1>(N / 2));
283+
queue1.submit([&](sycl::handler &cgh) {
284+
auto bufacc = subbuf1.get_access<sycl::access::mode::read_write>(cgh);
285+
cgh.parallel_for<class sub_buffer_3>(
286+
sycl::range<1>(N / 2), [=](sycl::id<1> idx) { bufacc[idx[0]] = -1; });
287+
});
288+
auto host_acc = subbuf1.get_access<sycl::access::mode::read>();
289+
assert(host_acc[0] == -1 && host_acc[N / 2 - 1] == -1 &&
290+
"Sub buffer data loss");
291+
}
278292
}
279293

280294
int main() {

0 commit comments

Comments
 (0)