为什么我们无法访问主机端的设备内存? [英] Why we do not have access to device memory on host side?

查看:138
本文介绍了为什么我们无法访问主机端的设备内存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问了一个问题使用cudaMalloc()分配的内存是否可以被主机访问?
,尽管现在情况对我来说已经很清楚了,但是我仍然想知道为什么无法访问其中的设备指针主办。我的理解是CUDA驱动程序负责GPU DRAM内部的内存分配。因此,此信息(即我在设备中分配的内存的第一个地址是什么)可以传递给主机上运行的OS。然后可以访问该设备指针,即已分配设备存储器的第一个地址。我的理解有什么问题?请帮助我理解这一点。谢谢

I asked a question Memory allocated using cudaMalloc() is accessable by host or not? though the things are much clear to me now, but I am still wondering why it is not possible to access the device pointer in host. My understanding is that the CUDA driver takes care of memory allocation inside GPU DRAM. So this information (that what is my first address of allocated memory in device), can be conveyed to the OS running on host. Then it can be possible to access this device pointer i.e the first address of the allocated device memory. What is wrong with my understanding ? Kindly help me to understand this. Thanks you

推荐答案

GPU内存位于PCIE总线的另一侧。现代PC体系结构中用于主机内存的内存控制器直接连接到CPU。

The GPU memory lives on the other side of the PCIE bus. The memory controller for the host memory in modern PC architectures is directly attached to the CPU.

因此,访问方法有很大不同。当访问GPU上的内存时,必须将事务按一系列PCIE周期进行划分。设置PCIE总线以实现此事务的活动并未内置在现代CPU的普通内存获取周期中。

Therefore the access methods are quite a bit different. When accessing memory that is on the GPU, the transaction must be framed as a sequence of PCIE cycles. The activity of setting up the PCIE bus to effect this transaction is not built into an ordinary memory fetch cycle in a modern CPU.

因此,我们需要软件交互(由 cudaMemcpy )来完成将对PCIE总线上的循环进行编程的软件序列,以发送或获取总线另一侧的数据。

Therefore we require software interaction (handled by cudaMemcpy) to complete the software sequence that will program cycles on the PCIE bus to either send or fetch data that is on the other side of the bus.

这篇关于为什么我们无法访问主机端的设备内存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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