mmap()设备内存进入用户空间 [英] mmap() device memory into user space

查看:141
本文介绍了mmap()设备内存进入用户空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说如果我们执行mmap()系统调用并将某些PCIE设备内存(例如GPU)映射到用户空间,则应用程序可以访问设备中的那些内存区域,而不会产生任何OS开销.数据可以直接从文件系统缓冲区复制到设备内存,而无需任何其他副本.

Saying if we do a mmap() system call and maps some PCIE device memory (like GPU) into the user space, then application can access those memory region in the device without any OS overhead. Data can by copied from file system buffer directly to device memory without any other copy.

以上声明必定是错误的...谁能告诉我漏洞在哪里?谢谢!

Above statement must be wrong... Can anyone tell me where is the flaw? Thanks!

推荐答案

对于普通设备,您所说的是正确的.如果GPU内存在读/写行为上有所不同,则可能会这样做.我们应该看看cudaMemcpy()的一些文档.

For a normal device what you have said is correct. If the GPU memory behaves differently for reads/write, they might do this. We should look at some documentation of cudaMemcpy().

来自 Nvidia的CUDA基础页面22,

方向指定 src dst 的位置(主机或设备) 阻止CPU线程:复制完成后返回. 在先前的CUDA调用完成之前,不会开始复制

direction specifies locations (host or device) of src and dst Blocks CPU thread: returns after the copy is complete. Doesn't start copying until previous CUDA calls complete

很显然,cudaMemcpy()与先前的GPU寄存器写入同步,这可能导致mmap()内存被更新.由于GPU管道是一条管道,因此从CPU发出cudaMemcpy()时,先前的命令问题可能尚未完成.

It seems pretty clear that the cudaMemcpy() is synchronized to prior GPU registers writes, which may have caused the mmap() memory to be updated. As the GPU pipeline is a pipeline, prior command issues may not have completed when cudaMemcpy() is issued from the CPU.

这篇关于mmap()设备内存进入用户空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆