I am trying to write data into an image buffer using image::write but it is causing an exception.
Input image img2 is a simple uchar4 rgba image and I just want to copy this image to new buffer (*out). If I comment out image3Ptr.write, I do not get an exception
uint4 *out = (uint4 *)calloc(fWidth * fHeight, sizeof(uchar4)); cl::sycl::image<2> img2(second, cl::sycl::image_channel_order::rgba, cl::sycl::image_channel_type::unsigned_int8, range<2>(sWidth, sHeight)); cl::sycl::image<2> img3(out, cl::sycl::image_channel_order::rgba, cl::sycl::image_channel_type::unsigned_int8, range<2>(sWidth, sHeight)); myQueue.submit([&](handler &cgh) { accessor<uint4, 2, access::mode::read, access::target::image> image2Ptr(img2, cgh); accessor<uint4, 2, access::mode::write, access::target::image> image3Ptr(img3, cgh); cgh.parallel_for<class nn_search1>( nd_range<2>(range<2>(fWidth, fHeight), range<2>(1, 1)), [=](nd_item<2> item) { auto idx = item.get_global_id(0); auto idy = item.get_global_id(1); uint4 v = image2Ptr.read((int2)(idx, idy)); image3Ptr.write((int2)(idx, idy), v); }); });
Exception details: Exception thrown at 0x00007FFA776BBACF (igc64.dll) in PatchMatch.exe: 0xC0000005: Access violation writing location 0x000000000000001A.
Visual studio takes me to handler.hpp, line 407
detail::EventImplPtr Event = detail::Scheduler::getInstance().addCG(
std::move(CommandGroup), std::move(MQueue));
and stack trace shows:
PatchMatch.exe!cl::sycl::handler::finalize() Line 407 C++
PatchMatch.exe!cl::sycl::detail::queue_impl::submit_impl<`lambda at ..\\source\\PM_SYCL.cpp:531:21'>(nn_search_sycl1::<unnamed-tag> cgf, std::shared_ptr<cl::sycl::detail::queue_impl> self) Line 212 C++
PatchMatch.exe!cl::sycl::detail::queue_impl::submit<`lambda at ..\\source\\PM_SYCL.cpp:531:21'>(nn_search_sycl1::<unnamed-tag> cgf, std::shared_ptr<cl::sycl::detail::queue_impl> self) Line 106 C++
PatchMatch.exe!cl::sycl::queue::submit<`lambda at ..\\source\\PM_SYCL.cpp:531:21'>(nn_search_sycl1::<unnamed-tag> cgf) Line 87 C++