Peer to peer device memory access#
-
hipError_t hipDeviceCanAccessPeer(int *canAccessPeer, int deviceId, int peerDeviceId)#
Determines if a device can access a peer device’s memory.
The value of
canAccessPeer
,Returns “1” if the specified
deviceId
is capable of directly accessing memory physically located onpeerDeviceId
,Returns “0” if the specified
deviceId
is not capable of directly accessing memory physically located onpeerDeviceId
.Returns “0” if
deviceId
==peerDeviceId
, both are valid devices, however, a device is not a peer of itself.Returns hipErrorInvalidDevice if deviceId or peerDeviceId are not valid devices
- Parameters:
canAccessPeer – [out] - Returns the peer access capability (0 or 1)
deviceId – [in] - The device accessing the peer device memory.
peerDeviceId – [in] - Peer device where memory is physically located
- Returns:
hipSuccess, hipErrorInvalidDevice
-
hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags)#
Enables direct access to memory allocations on a peer device.
When this API is successful, all memory allocations on peer device will be mapped into the address space of the current device. In addition, any future memory allocation on the peer device will remain accessible from the current device, until the access is disabled using hipDeviceDisablePeerAccess or device is reset using hipDeviceReset.
- Parameters:
peerDeviceId – [in] - Peer device to enable direct access to from the current device
flags – [in] - Reserved for future use, must be zero
- Returns:
hipSuccess, hipErrorInvalidDevice, hipErrorInvalidValue,
- Returns:
hipErrorPeerAccessAlreadyEnabled if peer access is already enabled for this device.
-
hipError_t hipDeviceDisablePeerAccess(int peerDeviceId)#
Disables direct access to memory allocations on a peer device.
If direct access to memory allocations on peer device has not been enabled yet from the current device, it returns hipErrorPeerAccessNotEnabled.
- Parameters:
peerDeviceId – [in] Peer device to disable direct access to
- Returns:
hipSuccess, hipErrorPeerAccessNotEnabled
-
hipError_t hipMemcpyPeer(void *dst, int dstDeviceId, const void *src, int srcDeviceId, size_t sizeBytes)#
Copies memory between two peer accessible devices.
- Parameters:
dst – [out] - Destination device pointer
dstDeviceId – [in] - Destination device
src – [in] - Source device pointer
srcDeviceId – [in] - Source device
sizeBytes – [in] - Size of memory copy in bytes
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidDevice
-
hipError_t hipMemcpyPeerAsync(void *dst, int dstDeviceId, const void *src, int srcDevice, size_t sizeBytes, hipStream_t stream)#
Copies memory between two peer accessible devices asynchronously.
- Parameters:
dst – [out] - Destination device pointer
dstDeviceId – [in] - Destination device
src – [in] - Source device pointer
srcDevice – [in] - Source device
sizeBytes – [in] - Size of memory copy in bytes
stream – [in] - Stream identifier
- Returns:
hipSuccess, hipErrorInvalidValue, hipErrorInvalidDevice