KhronosGroup / SYCL-Docs

SYCL Open Source Specification
Other
117 stars 68 forks source link

sycl::image explicit data movement #414

Open biggysmith opened 1 year ago

biggysmith commented 1 year ago

Hi,

I asked a question about how handle explicit sycl::image data movement and was encouraged to start a discussion here.

Specifically I wanted to know how to explicitly handle data movement between host/device when using sycl::image. Buffers have:

q.submit([&](sycl::handler& cgh) {
  auto acc = buf.get_access<sycl::access::mode::read>(cgh);
  cgh.copy(acc, host_ptr);
});

but no such equivalent seems to be available for sycl images. My previous OpenCL code had clEnqueueReadImage and clEnqueueWriteImage for this sort of data image transfer.

Could equivalent functionality be added to sycl? It would also be good for it to support sub image copies too, just like the OpenCL functions.

Thanks

gmlueck commented 1 year ago

Note that you can create a host accessor to the image. For example, SYCL 1.2.1 has access::target::host_image for this purpose and SYCL 2020 has host_unsampled_image_accessor and host_sampled_image_accessor.

I agree, though, that we do not have the equivalent to handler::copy for images.

biggysmith commented 1 year ago

using a host accessor helps me out here, but seems to be very slow when reading from the image. Copying to an image (512x512) with image.write takes ~1-4ms but copying from an image with image.read takes >100ms. Is host reading known to be slow?