The supported attributes are:
Returns in *data
the CUcontext in which ptr
was allocated or registered. The type of data
must be CUcontext *.
If ptr
was not allocated by, mapped by, or registered with a CUcontext which uses unified virtual addressing then CUDA_ERROR_INVALID_VALUE is returned.
Returns in *data
the physical memory type of the memory that ptr
addresses as a CUmemorytype enumerated value. The type of data
must be unsigned int.
If ptr
addresses device memory then *data
is set to CU_MEMORYTYPE_DEVICE. The particular CUdevice on which the memory resides is the CUdevice of the CUcontext returned by the CU_POINTER_ATTRIBUTE_CONTEXT attribute of ptr
.
If ptr
addresses host memory then *data
is set to CU_MEMORYTYPE_HOST.
If ptr
was not allocated by, mapped by, or registered with a CUcontext which uses unified virtual addressing then CUDA_ERROR_INVALID_VALUE is returned.
If the current CUcontext does not support unified virtual addressing then CUDA_ERROR_INVALID_CONTEXT is returned.
Returns in *data
the device pointer value through which ptr
may be accessed by kernels running in the current CUcontext. The type of data
must be CUdeviceptr *.
If there exists no device pointer value through which kernels running in the current CUcontext may access ptr
then CUDA_ERROR_INVALID_VALUE is returned.
If there is no current CUcontext then CUDA_ERROR_INVALID_CONTEXT is returned.
Except in the exceptional disjoint addressing cases discussed below, the value returned in *data
will equal the input value ptr
.
Returns in *data
the host pointer value through which ptr
may be accessed by by the host program. The type of data
must be void **. If there exists no host pointer value through which the host program may directly access ptr
then CUDA_ERROR_INVALID_VALUE is returned.
Except in the exceptional disjoint addressing cases discussed below, the value returned in *data
will equal the input value ptr
.
Note that for most allocations in the unified virtual address space the host and device pointer for accessing the allocation will be the same. The exceptions to this are
- user memory registered using cuMemHostRegister
- host memory allocated using cuMemHostAlloc with the CU_MEMHOSTALLOC_WRITECOMBINED flag For these types of allocation there will exist separate, disjoint host and device addresses for accessing the allocation. In particular
- The host address will correspond to an invalid unmapped device address (which will result in an exception if accessed from the device)
- The device address will correspond to an invalid unmapped host address (which will result in an exception if accessed from the host). For these types of allocations, querying CU_POINTER_ATTRIBUTE_HOST_POINTER and CU_POINTER_ATTRIBUTE_DEVICE_POINTER may be used to retrieve the host and device addresses from either address.
- Parameters:
-
| data | - Returned pointer attribute value |
| attribute | - Pointer attribute to query |
| ptr | - Pointer |
- Returns:
- CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_INVALID_VALUE, CUDA_ERROR_INVALID_DEVICE
- Note:
- Note that this function may also return error codes from previous, asynchronous launches.
- See also:
- cuMemAlloc, cuMemFree, cuMemAllocHost, cuMemFreeHost, cuMemHostAlloc, cuMemHostRegister, cuMemHostUnregister