Skip to main content

cudaPointerGetAttributes

Function cudaPointerGetAttributes 

Source
pub unsafe extern "C" fn cudaPointerGetAttributes(
    attributes: *mut cudaPointerAttributes,
    ptr: *const c_void,
) -> cudaError_t
Expand 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

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

See also: cudaGetDeviceCount, cudaGetDevice, cudaSetDevice, cudaChooseDevice, cudaInitDevice, cuPointerGetAttributes.