CUDA:零拷贝主机内存

Posted 那个人好像一条狗

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CUDA:零拷贝主机内存相关的知识,希望对你有一定的参考价值。

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:零拷贝主机内存的主要内容,如果未能解决你的问题,请参考以下文章

#01

CUDA编程GPU内存总结

CUDA编程GPU内存总结

CUDA 固定从设备刷新内存

CUDA C

CUDA 学习(十五)应用程序性能优化