码迷,mamicode.com
首页 > 其他好文 > 详细

CUDA:零拷贝主机内存

时间:2017-04-24 12:14:17      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:cep   ice   creat   use   size   nts   nic   locate   poi   

The easy way to achieve copy/compute overlap!
1.Enable Host Mapping*

Runtime: cudaSetDeviceFlags() with cudaDeviceMapHost flag
Driver : cuCtxCreate() with CU_CTX_MAP_HOST

2.Allocate pinned CPU memory

Runtime: cudaHostAlloc(), use cudaHostAllocMapped flag
Driver : cuMemHostAlloc()use CUDA_MEMHOSTALLOC_DEVICEMAP

3.Get a CUDA device pointer to this memory

Runtime: cudaHostGetDevicePointer()
Driver : cuMemHostGetDevicePointer()

4.Just use that pointer in your kernels! 

 

Zero-Copy Guidlines

?Data is transferred over the PCIe bus automatically, but it’s slow

?Use when data is only read/written once

?Use for very small amounts of data (new variables, CPU/GPU communication)

?Use when compute/memory ratio is very high and occupancy is high, so latency over PCIe is hidden
?Coalescing is critically important!

 

CUDA:零拷贝主机内存

标签:cep   ice   creat   use   size   nts   nic   locate   poi   

原文地址:http://www.cnblogs.com/programmer-wfq/p/6755481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!