9.3_UVA_Inferring_Device_from_Address

9.3 UVA: Inferring Device from Address

Since UVA is always enabled on peer-to-peer-capable systems, the address ranges for different devices do not overlap, and the driver can infer the owning device from a pointer value. The cuPointerGetAttribute() function may be used to query information about UVA pointers, including the owning context.

CUresult CUDAAPI cuPointerGetAttribute(void *data, CUpointer_attribute attribute, CUdeviceptr ptr);

cuPointerGetAttribute() orCORDATAmberGetAttributes() may be used to query the attributes of a pointer. Table 9.1 gives the values that can be passed into cuPointerGetAttribute(); the structure passed back byCORDATAmberGetAttributes() is as follows.

structCORDerAttributes {
    enumCORDMemoryTypememoryType;
    int device;
    void*devicePointer;
    void*hostPointer;
}

Table 9.1 cuPointerGetAttribute() Attributes

memoryType may beCORDMemoryTypeHost or codaMemoryTypeDevice.

device is the device for which the pointer was allocated. For device memory, device identifies the device where the memory corresponding to ptr was allocated. For host memory, device identifies the device that was current when the allocation was performed.

devicePointer gives the device pointer value that may be used to reference ptr from the current device. If ptr cannot be accessed by the current device, devicePointer is NULL.

hostPointer gives the host pointer value that may be used to reference ptr from the CPU. If ptr cannot be accessed by the current host, hostPointer is NULL.

9.3_UVA_Inferring_Device_from_Address - The CUDA Handbook | OpenTech