首页 > 其他 > 详细

opencl(6)读写传输命令、内存映射命令

时间:2020-01-09 21:27:08      阅读:130      评论:0      收藏:0      [点我收藏+]

1:将缓存对象的内容读到缓存对象中(从设备到主机)

cl_int clEnqueuReadBuffer(

cl_command_queue command_queue,  //命令队列

cl_mem buffer,               //  缓存对象

cl_bool blocking_read,          //是否堵塞CL_TRUE CL_FALSE

size_t offset,                //缓冲区起始偏移位置

size_t size,                //缓冲区大小大小

void *ptr,                  //宿主机内存中的指针,指示所读数据写到哪里

cl_uint num_events_wait_in_list,

const cl_event* event_wait_list,

cl_event *event

)

 

2:将主机内存写到缓冲对象中(从主机写到设备)

cl_int clEnqueueWriteBuffer(

cl_command_queue  command_queue,

cl_mem buffer,

cl_bool blocking_write,          //是否堵塞

size_t offset,

size_t size,

void* ptr,                 //从ptr指示的主机内存中的数据写到buffer

cl_uint num_events_waut_in_list,

const cl_event* event_wait_list,

cl_event* event

 

3:内存映射命令

1)将缓存对象中的区域映射到主机内存,返回映射指针

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)解映射

cl_int clEnqueueUnmapMemObject(

cl_command_queue command_queue,//命令队列

cl_mem memobj,           //缓存对象

void* mapped_ptr,          //映射指针

cl_uint num_events_in_wait_list,

const cl_event* event_wait_list,

cl_event* event

)

 

cl_map_flags:

CL_MAP_READ            映射完成读操作

CL_MAP_WRITE            映射完成写操作

CL_MAP_WRITE_INVALIDATE_REGION     

此标志指定在内存对象中映射的区域正在进行写入映射。

被映射区域的内容将被丢弃。这通常是被映射的区域被主机覆盖的情况。此标志允许实现不再保证由握力队列映射{Buffer|Image}返回的指针包含被映射区域的最新位,这是一个显著的性能增强。

opencl(6)读写传输命令、内存映射命令

原文:https://www.cnblogs.com/pengtangtang/p/PengTangTang_OpenCL_numberfive.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!