pub unsafe extern "C" fn cudaPointerGetAttributes(
attributes: *mut cudaPointerAttributes,
ptr: *const c_void,
) -> cudaError_tExpand description
Returns attributes about a specified pointer.
Returns in *attributes the attributes of the pointer ptr. If pointer was not allocated in, mapped by or registered with context supporting unified addressing cudaError_t::CUDA_ERROR_INVALID_VALUE is returned.
The cudaPointerAttributes structure is defined as:
struct cudaPointerAttributes {
enum cudaMemoryType type;
int device;
void *devicePointer;
void *hostPointer;
int localityDomainOrdinal;
}In this structure, the individual fields mean
cudaPointerAttributes::typeidentifies type of memory. It can becudaMemoryType::cudaMemoryTypeUnregisteredfor unregistered host memory,cudaMemoryType::cudaMemoryTypeHostfor registered host memory,cudaMemoryType::cudaMemoryTypeDevicefor device memory orcudaMemoryType::cudaMemoryTypeManagedfor managed memory.- device is the device against which
ptrwas allocated. Ifptrhas memory typecudaMemoryType::cudaMemoryTypeDevicethen this identifies the device on which the memory referred to byptrphysically resides. Ifptrhas memory typecudaMemoryType::cudaMemoryTypeHostthen this identifies the device which was current when the allocation was made (and if that device is deinitialized then this allocation will vanish with that device’s state). - devicePointer is the device pointer alias through which the memory referred to by
ptrmay be accessed on the current device. If the memory referred to byptrcannot be accessed directly by the current device then this is NULL. - hostPointer is the host pointer alias through which the memory referred to by
ptrmay be accessed on the host. If the memory referred to byptrcannot be accessed directly by the host then this is NULL. - localityDomainOrdinal is the locality domain ordinal for device allocations localized to a locality domain, or -1 when the allocation is not localized to a locality domain.
Note: In CUDA 11.0 forward passing host pointer will return cudaMemoryType::cudaMemoryTypeUnregistered in cudaPointerAttributes::type and call will return cudaError_t::CUDA_SUCCESS.
Note that this function may also return cudaError_t::CUDA_ERROR_NOT_INITIALIZED, cudaErrorInsufficientDriver or cudaError_t::CUDA_ERROR_NO_DEVICE if this call tries to initialize internal CUDA RT state.
Note that as specified by cudaStreamAddCallback no CUDA function may be called from callback. cudaError_t::CUDA_ERROR_NOT_PERMITTED may, but is not guaranteed to, be returned as a diagnostic in such case.
§Parameters
attributes: Attributes for the specified pointer.ptr: Pointer to get attributes for.
§Return value
cudaError_t::CUDA_SUCCESScudaError_t::CUDA_ERROR_INVALID_DEVICEcudaError_t::CUDA_ERROR_INVALID_VALUE
See also: cudaGetDeviceCount, cudaGetDevice, cudaSetDevice, cudaChooseDevice, cudaInitDevice, cuPointerGetAttributes.