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

Hi, Mike,

Thanks for your reply. Just one point to make sure:

After using cgh.copy(), do we still need to get device accessor from buffer in other queue submit body?

Tao

Hi Tao,

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?

Thanks,
Mike

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.