Added support for Primary Context Management APIs

Change-Id: I70f91b4492e112dd8e12ecf511fdc18a27944a06
Этот коммит содержится в:
Rahul Garg
2017-03-26 23:45:54 +05:30
родитель ec0d334354
Коммит ecc0e14cf7
3 изменённых файлов: 161 добавлений и 0 удалений
+76
Просмотреть файл
@@ -283,3 +283,79 @@ hipError_t hipCtxGetFlags ( unsigned int* flags )
*flags = tempCtx->_ctxFlags;
return ihipLogStatus(e);
}
hipError_t hipDevicePrimaryCtxGetState ( hipDevice_t dev, unsigned int* flags, int* active )
{
HIP_INIT_API(dev, flags, active);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
}
ihipCtx_t* tempCtx;
tempCtx = ihipGetTlsDefaultCtx();
ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx;
if(tempCtx == primaryCtx) {
*active = 1;
*flags = tempCtx->_ctxFlags;
} else {
*active = 0;
*flags = primaryCtx->_ctxFlags;
}
return ihipLogStatus(e);
}
hipError_t hipDevicePrimaryCtxRelease ( hipDevice_t dev)
{
HIP_INIT_API(dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
}
return ihipLogStatus(e);
}
hipError_t hipDevicePrimaryCtxRetain ( hipCtx_t* pctx, hipDevice_t dev )
{
HIP_INIT_API(pctx, dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
}
*pctx = deviceHandle->_primaryCtx;
return ihipLogStatus(e);
}
hipError_t hipDevicePrimaryCtxReset ( hipDevice_t dev )
{
HIP_INIT_API(dev);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
}
ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx;
primaryCtx->locked_reset();
return ihipLogStatus(e);
}
hipError_t hipDevicePrimaryCtxSetFlags ( hipDevice_t dev, unsigned int flags )
{
HIP_INIT_API(dev, flags);
hipError_t e = hipSuccess;
auto deviceHandle = ihipGetDevice(dev);
if (deviceHandle == NULL) {
e = hipErrorInvalidDevice;
} else {
e = hipErrorContextAlreadyInUse;
}
return ihipLogStatus(e);
}