Mapping buffer objects
OpenCL provides a mechanism to map a region of a buffer directly into host memory instead of using the clEnqueue[Read|Write]Buffer
functions. These mapped regions can be returned to the application. The application can use this mapped memory region based on the cl_map_flags
flag value which is set during mapping. Now the first question which would arise in the readers mind is that how different are the two APIs clEnqueueMapBuffer
and clEnqueueReadBuffer
.
The clEnqueueReadBuffer
function reads into a memory location pre-allocated. But clEnqueueMapBuffer
returns a pointer to the mapped region.
Other difference between clEnqueueReadBuffer
and clEnqueueMapBuffer
is the map_flags
argument. If map_flags
is set to CL_MAP_READ
, the ...
Get OpenCL Programming by Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.