有与 cudaHostGetDevicePointer() 相反的东西吗?

Is there an opposite to cudaHostGetDevicePointer()?

假设我的设备是 Kepler 及以上,CUDA 是 6.5 或以上,我的驱动程序最早是 2015 年的。

是否可以做与cudaHostGetDevicePointer()相反的事情?即提供一些映射内存的设备端表现的地址,获取主机地址?

如果你运行在支持统一寻址的平台上,你可以调用cudaPointerGetAttributes在统一寻址中注册或分配的任何指针地址 space。函数returns一个结构

  struct cudaPointerAttributes {
          enum cudaMemoryType memoryType;
          int device;
          void *devicePointer;
          void *hostPointer;
          int isManaged;
      }

它将告诉您内存的设备地址和主机地址,以及它实际驻留在哪个设备上,或者它最初注册在哪个设备上下文中(对于主机内存)。

如果您无法访问统一寻址,我认为没有办法实现这一目标。