opencl (6) to read and write transfer command memory mapping command

1: The contents of the cache to read the object in the object cache (from the device to the host)

cl_int clEnqueuReadBuffer(

cl_command_queue command_queue, // Command Queuing

cl_mem buffer, // cache object

cl_bool blocking_read, // is blocked CL_TRUE CL_FALSE

size_t offset, // beginning offset buffer

size_t size, // size of the buffer size

Where void * ptr, // pointer to the host memory, the read data is written indicating

cl_uint num_events_wait_in_list,

const cl_event* event_wait_list,

cl_event *event

)

 

2: The write buffer object host memory (written from the host device)

cl_int clEnqueueWriteBuffer(

cl_command_queue  command_queue,

cl_mem buffer,

cl_bool blocking_write, // is blocked

size_t offset,

size_t size,

void * ptr, // ptr data written to host memory indicated in the buffer

cl_uint num_events_waut_in_list,

const cl_event* event_wait_list,

cl_event* event

 

3: memory-mapped command

1) maps to a region of the buffer object host memory mapped pointer returns

void* clEnqueueMapBuffer(

cl_command_queue command_queue,

cl_mem buffer,

cl_bool blocking_map,

cl_map_flags map_flags,

size_t offset,

size_t size,

cl_uint num_events_wait_in_list,

const cl_event* event_wait_list,

cl_event* event,

cl_int *errcode_ret

)

 

2) de-mapping

cl_int clEnqueueUnmapMemObject(

cl_command_queue command_queue, // Command Queuing

cl_mem memobj, // cache object

void * mapped_ptr, // pointer map

cl_uint num_events_in_wait_list,

const cl_event* event_wait_list,

cl_event* event

)

 

cl_map_flags:

CL_MAP_READ map read operation

CL_MAP_WRITE write operation to complete the map

CL_MAP_WRITE_INVALIDATE_REGION     

This flag specifies the object in memory is written in the mapping area being mapped.

Content is mapped region will be discarded. This is typically the case mapped region is covered with the host. This flag allows longer guaranteed {Buffer | Image} grip by the latest bit map returned to the queue pointer contains the mapped area, which is a significant performance enhancement.

Guess you like

Origin www.cnblogs.com/pengtangtang/p/PengTangTang_OpenCL_numberfive.html