6.32. Peer Context Memory Access
This section describes the direct peer context memory access functions of the low-level CUDA driver application programming interface.
Functions
- CUresult cuCtxDisablePeerAccess(CUcontext peerContext)
Disables direct access to memory allocations in a peer context and unregisters any registered allocations.
- CUresult cuCtxEnablePeerAccess(CUcontext peerContext, unsigned int Flags)
Enables direct access to memory allocations in a peer context.
- CUresult cuDeviceCanAccessPeer(int *canAccessPeer, CUdevice dev, CUdevice peerDev)
Queries if a device may directly access a peer device's memory.
- CUresult cuDeviceGetP2PAtomicCapabilities(unsigned int *capabilities, const CUatomicOperation *operations, unsigned int count, CUdevice srcDevice, CUdevice dstDevice)
Queries details about atomic operations supported between two devices.
- CUresult cuDeviceGetP2PAttribute(int *value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice)
Queries attributes of the link between two devices.
6.32.1. Functions
-
CUresult cuCtxDisablePeerAccess(CUcontext peerContext)
Disables direct access to memory allocations in a peer context and unregisters any registered allocations.
Returns CUDA_ERROR_PEER_ACCESS_NOT_ENABLED if direct peer access has not yet been enabled from
peerContextto the current context.Returns CUDA_ERROR_INVALID_CONTEXT if there is no current context, or if
peerContextis not a valid context.See also
cuDeviceCanAccessPeer, cuCtxEnablePeerAccess, ::cudaDeviceDisablePeerAccess
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
peerContext – - Peer context to disable direct access to
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_PEER_ACCESS_NOT_ENABLED, CUDA_ERROR_INVALID_CONTEXT,
-
CUresult cuCtxEnablePeerAccess(CUcontext peerContext, unsigned int Flags)
Enables direct access to memory allocations in a peer context.
If both the current context and
peerContextare on devices which support unified addressing (as may be queried using CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING) and same major compute capability, then on success all allocations frompeerContextwill immediately be accessible by the current context. See Unified Addressing for additional details.Note that access granted by this call is unidirectional and that in order to access memory from the current context in
peerContext, a separate symmetric call to cuCtxEnablePeerAccess() is required.Note that there are both device-wide and system-wide limitations per system configuration, as noted in the CUDA Programming Guide under the section “Peer-to-Peer Memory Access”.
Returns CUDA_ERROR_PEER_ACCESS_UNSUPPORTED if cuDeviceCanAccessPeer() indicates that the CUdevice of the current context cannot directly access memory from the CUdevice of
peerContext.Returns CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED if direct access of
peerContextfrom the current context has already been enabled.Returns CUDA_ERROR_TOO_MANY_PEERS if direct peer access is not possible because hardware resources required for peer access have been exhausted.
Returns CUDA_ERROR_INVALID_CONTEXT if there is no current context,
peerContextis not a valid context, or if the current context ispeerContext.Returns CUDA_ERROR_INVALID_VALUE if
Flagsis not 0.See also
cuDeviceCanAccessPeer, cuCtxDisablePeerAccess, ::cudaDeviceEnablePeerAccess
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
peerContext – - Peer context to enable direct access to from the current context
Flags – - Reserved for future use and must be set to 0
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED, CUDA_ERROR_TOO_MANY_PEERS, CUDA_ERROR_INVALID_CONTEXT, CUDA_ERROR_PEER_ACCESS_UNSUPPORTED, CUDA_ERROR_INVALID_VALUE
-
CUresult cuDeviceCanAccessPeer(int *canAccessPeer, CUdevice dev, CUdevice peerDev)
Queries if a device may directly access a peer device’s memory.
Returns in
*canAccessPeera value of 1 if contexts ondevare capable of directly accessing memory from contexts onpeerDevand 0 otherwise. If direct access ofpeerDevfromdevis possible, then access may be enabled on two specific contexts by calling cuCtxEnablePeerAccess().See also
cuCtxEnablePeerAccess, cuCtxDisablePeerAccess, ::cudaDeviceCanAccessPeer
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
canAccessPeer – - Returned access capability
dev – - Device from which allocations on
peerDevare to be directly accessed.peerDev – - Device on which the allocations to be directly accessed by
devreside.
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_DEVICE
-
CUresult cuDeviceGetP2PAtomicCapabilities(unsigned int *capabilities, const CUatomicOperation *operations, unsigned int count, CUdevice srcDevice, CUdevice dstDevice)
Queries details about atomic operations supported between two devices.
Returns in
*capabilitiesthe details about requested atomic*operationsover the the link betweensrcDeviceanddstDevice. The allocated size of*operationsand*capabilitiesmust becount.For each CUatomicOperation in
*operations, the corresponding result in*capabilitieswill be a bitmask indicating which of CUatomicOperationCapability the link supports natively.Returns CUDA_ERROR_INVALID_DEVICE if
srcDeviceordstDeviceare not valid or if they represent the same device.Returns CUDA_ERROR_INVALID_VALUE if
*capabilitiesor*operationsis NULL, ifcountis 0, or if any of*operationsis not valid.See also
cuDeviceGetP2PAttribute, ::cudaDeviceGetP2PAttribute, ::cudaDeviceGetP2PAtomicCapabilities
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
capabilities – - Returned capability details of each requested operation
operations – - Requested operations
count – - Count of requested operations and size of capabilities
srcDevice – - The source device of the target link
dstDevice – - The destination device of the target link
- Returns
CUDA_SUCCESS, CUDA_ERROR_INVALID_DEVICE, CUDA_ERROR_INVALID_VALUE
-
CUresult cuDeviceGetP2PAttribute(int *value, CUdevice_P2PAttribute attrib, CUdevice srcDevice, CUdevice dstDevice)
Queries attributes of the link between two devices.
Returns in
*valuethe value of the requested attributeattribof the link betweensrcDeviceanddstDevice. The supported attributes are:CU_DEVICE_P2P_ATTRIBUTE_PERFORMANCE_RANK: A relative value indicating the performance of the link between two devices.
CU_DEVICE_P2P_ATTRIBUTE_ACCESS_SUPPORTED P2P: 1 if P2P Access is enable.
CU_DEVICE_P2P_ATTRIBUTE_NATIVE_ATOMIC_SUPPORTED: 1 if all CUDA-valid atomic operations over the link are supported.
CU_DEVICE_P2P_ATTRIBUTE_CUDA_ARRAY_ACCESS_SUPPORTED: 1 if cudaArray can be accessed over the link.
CU_DEVICE_P2P_ATTRIBUTE_ONLY_PARTIAL_NATIVE_ATOMIC_SUPPORTED: 1 if some CUDA-valid atomic operations over the link are supported. Information about specific operations can be retrieved with cuDeviceGetP2PAtomicCapabilities.
Returns CUDA_ERROR_INVALID_DEVICE if
srcDeviceordstDeviceare not valid or if they represent the same device.Returns CUDA_ERROR_INVALID_VALUE if
attribis not valid or ifvalueis a null pointer.See also
cuCtxEnablePeerAccess, cuCtxDisablePeerAccess, cuDeviceCanAccessPeer, cuDeviceGetP2PAtomicCapabilities, ::cudaDeviceGetP2PAttribute
Note
Note that this function may also return error codes from previous, asynchronous launches.
- Parameters
value – - Returned value of the requested attribute
attrib – - The requested attribute of the link between
srcDeviceanddstDevice.srcDevice – - The source device of the target link.
dstDevice – - The destination device of the target link.
- Returns
CUDA_SUCCESS, CUDA_ERROR_DEINITIALIZED, CUDA_ERROR_NOT_INITIALIZED, CUDA_ERROR_INVALID_DEVICE, CUDA_ERROR_INVALID_VALUE