Context management related changes in HIP.

-
-Contexts across threads are listed under device
-Device reset cleans up all contexts and re-initializes _primaryCtx

Change-Id: Ie1cfbb26d43a8dc6869be3e6ebaf7344ce374643
Αυτή η υποβολή περιλαμβάνεται σε:
Rahul Garg
2017-02-27 15:17:11 +05:30
γονέας 4a6166cd86
υποβολή bddd6b73c0
4 αρχεία άλλαξαν με 128 προσθήκες και 9 διαγραφές
+14 -3
Προβολή Αρχείου
@@ -58,9 +58,15 @@ hipError_t hipCtxCreate(hipCtx_t *ctx, unsigned int flags, hipDevice_t device)
HIP_INIT_API(ctx, flags, device); // FIXME - review if we want to init
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(device);
*ctx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags);
ihipSetTlsDefaultCtx(*ctx);
tls_ctxStack.push(*ctx);
{
// Obtain mutex access to the device critical data, release by destructor
LockedAccessor_DeviceCrit_t deviceCrit(deviceHandle->criticalData());
auto ictx = new ihipCtx_t(deviceHandle, g_deviceCnt, flags);
*ctx = ictx;
ihipSetTlsDefaultCtx(*ctx);
tls_ctxStack.push(*ctx);
deviceCrit->addContext(ictx);
}
return ihipLogStatus(e);
}
@@ -125,6 +131,11 @@ hipError_t hipCtxDestroy(hipCtx_t ctx)
//need to destroy the ctx associated with calling thread
tls_ctxStack.pop();
}
{
auto deviceHandle = ctx->getWriteableDevice();
deviceHandle->locked_removeContext(ctx);
ctx->locked_reset();
}
delete ctx; //As per CUDA docs , attempting to access ctx from those threads which has this ctx as current, will result in the error HIP_ERROR_CONTEXT_IS_DESTROYED.
}