For P2P, use the peer list when allocating Device memory or pinned host.

Each new allocation is automatically mapped into the address space of
all enabled peers.


[ROCm/clr commit: 97772d6363]
Tá an tiomantas seo le fáil i:
Ben Sander
2016-04-06 16:44:31 -05:00
tuismitheoir 7eb8c10215
tiomantas 2890517a23
D'athraigh 6 comhad le 59 breiseanna agus 38 scriosta
+17 -7
Féach ar an gComhad
@@ -20,7 +20,6 @@ THE SOFTWARE.
#include "hip_runtime.h"
#include "hcc_detail/hip_hcc.h"
#include "hcc_detail/trace_helper.h"
#define USE_PEER_TO_PEER 1
/**
* @warning HCC returns 0 in *canAccessPeer ; Need to update this function when RT supports P2P
@@ -67,15 +66,26 @@ hipError_t hipDeviceDisablePeerAccess (int peerDeviceId)
auto thisDevice = ihipGetTlsDefaultDevice();
auto peerDevice = ihipGetDevice(peerDeviceId);
if ((thisDevice != NULL) && (peerDevice != NULL)) {
LockedAccessor_DeviceCrit_t crit(thisDevice->criticalData());
bool changed = crit->removePeer(peerDevice);
if (changed) {
#if USE_PEER_TO_PEER==2
am_memtracker_update_peers(device->_acc, crit->peerCnt(), crit->peerAgents());
bool canAccessPeer = peerDevice->_acc.get_is_peer(device->_acc);
#else
bool canAccessPeer = 0;
#endif
if (! canAccessPeer) {
err = hipErrorInvalidDevice; // P2P not allowed between these devices.
} else {
err = hipErrorPeerAccessNotEnabled; // never enabled P2P access.
}
LockedAccessor_DeviceCrit_t crit(thisDevice->criticalData());
bool changed = crit->removePeer(peerDevice);
if (changed) {
#if USE_PEER_TO_PEER==2
am_memtracker_update_peers(device->_acc, crit->peerCnt(), crit->peerAgents());
#endif
} else {
err = hipErrorPeerAccessNotEnabled; // never enabled P2P access.
}
}
} else {
err = hipErrorInvalidDevice;
}