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?
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.
If using buffers to encapsulate data, then yes, you need to get accessors within each command group (“queue submit body”) for any data used within that command group/submission.
I might be misunderstanding your question, though. If so, can you please paste a small snip of code showing what you’re wondering about?