Fix bug with peer-to-peer combined with context API
- Store context inside the tracker rather than using int deviceID that was always mapped to primary context - IsPeerWatcher now based on device IDs rather than specific peers.
This commit is contained in:
+32
-5
@@ -47,6 +47,9 @@ THE SOFTWARE.
|
||||
#include "trace_helper.h"
|
||||
#include "env.h"
|
||||
|
||||
//TODO - create a stream-based debug interface as an additional option for tprintf
|
||||
#define DB_PEER_CTX 0
|
||||
|
||||
|
||||
//=================================================================================================
|
||||
//Global variables:
|
||||
@@ -459,8 +462,20 @@ void ihipCtxCriticalBase_t<CtxMutex>::recomputePeerAgents()
|
||||
template<>
|
||||
bool ihipCtxCriticalBase_t<CtxMutex>::isPeerWatcher(const ihipCtx_t *peer)
|
||||
{
|
||||
auto match = std::find(_peers.begin(), _peers.end(), peer);
|
||||
auto match = std::find_if(_peers.begin(), _peers.end(),
|
||||
[=] (const ihipCtx_t *d) { return d->getDeviceNum() == peer->getDeviceNum(); });
|
||||
|
||||
return (match != std::end(_peers));
|
||||
|
||||
#if 0
|
||||
for (auto pi=_peers.begin(); pi != _peers.end(); pi++) {
|
||||
if ((*pi)->getDeviceNum() == peer->getDeviceNum()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1677,18 +1692,24 @@ const char *ihipErrorString(hipError_t hip_error)
|
||||
// So we check dstCtx's and srcCtx's peerList to see if the both include thisCtx.
|
||||
bool ihipStream_t::canSeeMemory(const ihipCtx_t *copyEngineCtx, const hc::AmPointerInfo *dstPtrInfo, const hc::AmPointerInfo *srcPtrInfo)
|
||||
{
|
||||
|
||||
// Make sure this is a device-to-device copy with all memory available to the requested copy engine
|
||||
//
|
||||
// TODO - pointer-info stores a deviceID not a context,may have some unusual side-effects here:
|
||||
if (dstPtrInfo->_sizeBytes == 0) {
|
||||
return false;
|
||||
} else {
|
||||
#if USE_APP_PTR_FOR_CTX
|
||||
ihipCtx_t *dstCtx = static_cast<ihipCtx_t*> (dstPtrInfo->_appPtr);
|
||||
#else
|
||||
ihipCtx_t *dstCtx = ihipGetPrimaryCtx(dstPtrInfo->_appId);
|
||||
#endif
|
||||
if (copyEngineCtx != dstCtx) {
|
||||
// Only checks peer list if contexts are different
|
||||
LockedAccessor_CtxCrit_t ctxCrit(dstCtx->criticalData());
|
||||
//tprintf(DB_SYNC, "dstCrit lock succeeded\n");
|
||||
#if DB_PEER_CTX
|
||||
std::cerr << "checking peer : copyEngineCtx =" << copyEngineCtx << " dstCtx =" << dstCtx << " peerCnt="
|
||||
<< ctxCrit->peerCnt() << "\n";
|
||||
#endif
|
||||
if (!ctxCrit->isPeerWatcher(copyEngineCtx)) {
|
||||
return false;
|
||||
};
|
||||
@@ -1696,16 +1717,22 @@ bool ihipStream_t::canSeeMemory(const ihipCtx_t *copyEngineCtx, const hc::AmPoin
|
||||
}
|
||||
|
||||
|
||||
|
||||
// TODO - pointer-info stores a deviceID not a context,may have some unusual side-effects here:
|
||||
if (srcPtrInfo->_sizeBytes == 0) {
|
||||
return false;
|
||||
} else {
|
||||
#if USE_APP_PTR_FOR_CTX
|
||||
ihipCtx_t *srcCtx = static_cast<ihipCtx_t*> (srcPtrInfo->_appPtr);
|
||||
#else
|
||||
ihipCtx_t *srcCtx = ihipGetPrimaryCtx(srcPtrInfo->_appId);
|
||||
#endif
|
||||
if (copyEngineCtx != srcCtx) {
|
||||
// Only checks peer list if contexts are different
|
||||
LockedAccessor_CtxCrit_t ctxCrit(srcCtx->criticalData());
|
||||
//tprintf(DB_SYNC, "srcCrit lock succeeded\n");
|
||||
#if DB_PEER_CTX
|
||||
std::cerr << "checking peer : copyEngineCtx =" << copyEngineCtx << " srcCtx =" << srcCtx << " peerCnt="
|
||||
<< ctxCrit->peerCnt() << "\n";
|
||||
#endif
|
||||
if (!ctxCrit->isPeerWatcher(copyEngineCtx)) {
|
||||
return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user