Reputation: 13195
I am creating a buffer using CL_MEM_READ_ONLY | CL_MEM_ALLOC_HOST_PTR
.
I only want to copy memory one way, from host to device.
I am using clEnqueueMapBuffer
to get a host pointer, and clEnqueueUnmapBuffer
to copy the data to device.
When I call clEnqueueMapBuffer
, does this trigger a copy of memory from device to host?
Upvotes: 0
Views: 393
Reputation: 9925
If you are using CL_MAP_WRITE
, then it will likely incur a device to host memory copy. The spec says:
The pointer returned by
clEnqueueMap{Buffer | Image}
is guaranteed to contain the latest bits in the region being mapped when theclEnqueueMap{Buffer | Image}
command has completed
If you are using OpenCL 1.2, then you can use CL_MAP_WRITE_INVALIDATE_REGION
to indicate that you intend to overwrite the entire mapped region from the host, which means that the runtime need not copy any data from the device to the host.
Upvotes: 2