Skip to content

[SYCL] Fix bug with not found alloca command. #148

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
9 changes: 6 additions & 3 deletions sycl/source/detail/scheduler/graph_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,21 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr<detail::CG> CommandGroup,
break;
}
AllocaCommand *AllocaCmd = findAllocaForReq(Record, Req, Queue);
UpdateLeafs(Deps, Record, Req);

for (Command *Dep : Deps) {
NewCmd->addDep(DepDesc{Dep, Req, AllocaCmd});
Dep->addUser(NewCmd.get());
}
}

for (Requirement *Req : Reqs) {
// Set new command as user for dependencies and update leafs.
for (DepDesc &Dep : NewCmd->MDeps) {
Dep.MDepCommand->addUser(NewCmd.get());
Requirement *Req = Dep.MReq;
MemObjRecord *Record = getMemObjRecord(Req->MSYCLMemObj);
UpdateLeafs({Dep.MDepCommand}, Record, Req);
AddNodeToLeafs(Record, NewCmd.get(), Req);
}

return NewCmd.release();
}

Expand Down
26 changes: 26 additions & 0 deletions sycl/test/basic_tests/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,30 @@ int main() {
}
}
}

// Two accessors to the same buffer.
{
try {
sycl::queue queue;
int array[3] = {1, 1, 1};
sycl::buffer<int, 1> buf(array, sycl::range<1>(3));

queue.submit([&](sycl::handler& cgh) {
auto acc1 = buf.get_access<sycl::access::mode::read>(cgh);
auto acc2 = buf.get_access<sycl::access::mode::read_write>(cgh);

cgh.parallel_for<class two_accessors_to_buf>(
sycl::range<1>{3},
[=](sycl::id<1> index) { acc2[index] = 41 + acc1[index]; });
});

auto host_acc = buf.get_access<sycl::access::mode::read>();
for (int i = 0; i != 3; ++i)
assert(host_acc[i] == 42);

} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
}
}
}