Skip to content

[SYCL] Fix segfault upon initial complex call to set_final_data(null) #1004

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 3 commits into from
Jan 15, 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
13 changes: 8 additions & 5 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,14 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {

template <typename Destination>
EnableIfOutputPointerT<Destination> set_final_data(Destination FinalData) {
MUploadDataFunctor = [this, FinalData]() {
EventImplPtr Event = updateHostMemory(FinalData);
if (Event)
Event->wait(Event);
};
if (!FinalData)
MUploadDataFunctor = nullptr;
else
MUploadDataFunctor = [this, FinalData]() {
EventImplPtr Event = updateHostMemory(FinalData);
if (Event)
Event->wait(Event);
};
}

template <typename Destination>
Expand Down
25 changes: 25 additions & 0 deletions sycl/test/basic_tests/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,31 @@ int main() {
});
}

// image with write accessor to it in kernel
{
int NX = 32;
int NY = 32;

sycl::image<2> Img(sycl::image_channel_order::rgba,
sycl::image_channel_type::fp32,
sycl::range<2>(NX, NY));

sycl::queue Q;
Q.submit([&](sycl::handler &CGH) {
auto ImgAcc = Img.get_access<sycl::float4, sycl::access::mode::write>(
CGH);

sycl::nd_range<2> Rng(sycl::range<2>(NX, NY), sycl::range<2>(16, 16));

CGH.parallel_for<class sample>(Rng, [=](sycl::nd_item<2> Item) {
sycl::id<2> Idx = Item.get_global_id();
sycl::float4 C(0.5f, 0.5f, 0.2f, 1.0f);
ImgAcc.write(sycl::int2(Idx[0], Idx[1]), C);
});

}).wait_and_throw();
}

std::cout << "Success" << std::endl;
return 0;
}