Explicitly copy data from host to device for later usage

Hello,

I’m a newbie of SYCL. If I get it right, SYCL copies data between host and device automatically when the Buffer class is accessed. I wonder if the data will be copied each time when it is required?

Since in my program, I have a set of data which is going to be used many times for many kernels. I prefer to transfer it firstly and avoid repeatedly copying it during each kernel call.

I read the tutorial and find that there is a function of class Handler to achieve this: sycl::handler cgh.copy(), do you have any example codes for it?

Sincerely,
Tao

Hi Tao,

A good SYCL implementation should only move data if it needs to move for functionality, so if you run a series of kernels on a device using the same data, I wouldn’t expect you to see unnecessary copies under the hood.

I’d suggest that you run your code with a profiler, and check whether there are any unexpected copies being performed by the SYCL runtime. If you see any then you can start to think about manual data movement, but you should also file a performance bug with the vendor building the implementation that you’re using.

Thanks for starting this thread!
Mike

1 Like