2016-08-08 17:49:02 -05:00
|
|
|
/*
|
2017-03-31 12:11:34 -05:00
|
|
|
Copyright (c) 2015 - present Advanced Micro Devices, Inc. All rights reserved.
|
2016-10-15 22:55:22 +05:30
|
|
|
|
2016-08-08 17:49:02 -05:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
furnished to do so, subject to the following conditions:
|
2016-10-15 22:55:22 +05:30
|
|
|
|
2016-08-08 17:49:02 -05:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
|
all copies or substantial portions of the Software.
|
2016-10-15 22:55:22 +05:30
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
2016-08-08 17:49:02 -05:00
|
|
|
THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
//---
|
|
|
|
|
// Driver initialization and reporting:
|
|
|
|
|
|
|
|
|
|
#include <stack>
|
|
|
|
|
|
2016-10-04 22:17:18 +05:30
|
|
|
#include "hip/hip_runtime.h"
|
2017-03-31 12:11:34 -05:00
|
|
|
#include "hip_hcc_internal.h"
|
2016-10-15 20:25:20 -05:00
|
|
|
#include "trace_helper.h"
|
2016-08-08 17:49:02 -05:00
|
|
|
|
2016-08-17 16:28:22 +05:30
|
|
|
// Stack of contexts
|
2018-03-12 11:29:03 +05:30
|
|
|
thread_local std::stack<ihipCtx_t*> tls_ctxStack;
|
2017-08-08 07:02:22 +05:30
|
|
|
thread_local bool tls_getPrimaryCtx = true;
|
2016-08-08 17:49:02 -05:00
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
void ihipCtxStackUpdate() {
|
|
|
|
|
if (tls_ctxStack.empty()) {
|
|
|
|
|
tls_ctxStack.push(ihipGetTlsDefaultCtx());
|
2016-08-26 19:03:23 +05:30
|
|
|
}
|
|
|
|
|
}
|
2016-08-08 17:49:02 -05:00
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipInit(unsigned int flags) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipInit, flags);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
2016-08-08 17:49:02 -05:00
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
|
|
|
|
|
// Flags must be 0
|
|
|
|
|
if (flags != 0) {
|
|
|
|
|
e = hipErrorInvalidValue;
|
2016-08-17 16:28:22 +05:30
|
|
|
}
|
2016-08-08 17:49:02 -05:00
|
|
|
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxCreate(hipCtx_t* ctx, unsigned int flags, hipDevice_t device) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxCreate, ctx, flags, device); // FIXME - review if we want to init
|
2016-08-08 17:49:02 -05:00
|
|
|
hipError_t e = hipSuccess;
|
2016-12-17 16:53:03 +05:30
|
|
|
auto deviceHandle = ihipGetDevice(device);
|
2017-02-27 15:17:11 +05:30
|
|
|
{
|
2018-03-12 11:29:03 +05:30
|
|
|
// 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);
|
2017-08-08 07:02:22 +05:30
|
|
|
tls_getPrimaryCtx = false;
|
2018-03-12 11:29:03 +05:30
|
|
|
deviceCrit->addContext(ictx);
|
2017-02-27 15:17:11 +05:30
|
|
|
}
|
2016-08-08 17:49:02 -05:00
|
|
|
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDeviceGet(hipDevice_t* device, int deviceId) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDeviceGet, device, deviceId); // FIXME - review if we want to init
|
2016-08-08 17:49:02 -05:00
|
|
|
|
2016-12-17 16:53:03 +05:30
|
|
|
auto deviceHandle = ihipGetDevice(deviceId);
|
2016-08-08 17:49:02 -05:00
|
|
|
|
|
|
|
|
hipError_t e = hipSuccess;
|
2016-12-17 16:53:03 +05:30
|
|
|
if (deviceHandle == NULL) {
|
2016-08-08 17:49:02 -05:00
|
|
|
e = hipErrorInvalidDevice;
|
2016-12-17 16:53:03 +05:30
|
|
|
} else {
|
|
|
|
|
*device = deviceId;
|
2016-08-08 17:49:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
};
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDriverGetVersion(int* driverVersion) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDriverGetVersion, driverVersion);
|
2016-09-22 15:21:23 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2016-08-08 17:49:02 -05:00
|
|
|
if (driverVersion) {
|
|
|
|
|
*driverVersion = 4;
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
2016-09-22 15:21:23 +05:30
|
|
|
e = hipErrorInvalidValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipRuntimeGetVersion(int* runtimeVersion) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipRuntimeGetVersion, runtimeVersion);
|
2016-09-22 15:21:23 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
if (runtimeVersion) {
|
|
|
|
|
*runtimeVersion = HIP_VERSION_PATCH;
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
2016-09-22 15:21:23 +05:30
|
|
|
e = hipErrorInvalidValue;
|
|
|
|
|
}
|
2016-08-08 17:49:02 -05:00
|
|
|
|
2016-09-22 15:21:23 +05:30
|
|
|
return ihipLogStatus(e);
|
2016-08-08 17:49:02 -05:00
|
|
|
}
|
2016-08-13 00:09:08 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxDestroy(hipCtx_t ctx) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxDestroy, ctx);
|
2016-08-13 00:09:08 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2018-03-12 11:29:03 +05:30
|
|
|
ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx();
|
|
|
|
|
ihipCtx_t* primaryCtx = ((ihipDevice_t*)ctx->getDevice())->_primaryCtx;
|
|
|
|
|
if (primaryCtx == ctx) {
|
2016-08-26 19:03:23 +05:30
|
|
|
e = hipErrorInvalidValue;
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
2018-03-12 11:29:03 +05:30
|
|
|
if (currentCtx == ctx) {
|
|
|
|
|
// need to destroy the ctx associated with calling thread
|
2016-08-26 19:03:23 +05:30
|
|
|
tls_ctxStack.pop();
|
|
|
|
|
}
|
2017-02-27 15:17:11 +05:30
|
|
|
{
|
2018-03-12 11:29:03 +05:30
|
|
|
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.
|
2016-08-13 00:09:08 +05:30
|
|
|
}
|
2016-08-26 19:03:23 +05:30
|
|
|
|
2016-08-13 00:09:08 +05:30
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxPopCurrent(hipCtx_t* ctx) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxPopCurrent, ctx);
|
2016-08-13 00:09:08 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2017-08-08 07:02:22 +05:30
|
|
|
ihipCtx_t* currentCtx = ihipGetTlsDefaultCtx();
|
|
|
|
|
auto deviceHandle = currentCtx->getDevice();
|
|
|
|
|
*ctx = currentCtx;
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
if (!tls_ctxStack.empty()) {
|
2016-08-17 16:28:22 +05:30
|
|
|
tls_ctxStack.pop();
|
|
|
|
|
}
|
2017-08-08 07:02:22 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
if (!tls_ctxStack.empty()) {
|
|
|
|
|
currentCtx = tls_ctxStack.top();
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
|
|
|
|
currentCtx = deviceHandle->_primaryCtx;
|
2016-08-13 00:09:08 +05:30
|
|
|
}
|
2016-08-17 16:28:22 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
ihipSetTlsDefaultCtx(currentCtx); // TOD0 - Shall check for NULL?
|
2016-08-13 00:09:08 +05:30
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxPushCurrent(hipCtx_t ctx) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxPushCurrent, ctx);
|
2016-08-13 00:09:08 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2018-03-12 11:29:03 +05:30
|
|
|
if (ctx != NULL) { // TODO- is this check needed?
|
2016-08-13 00:09:08 +05:30
|
|
|
ihipSetTlsDefaultCtx(ctx);
|
|
|
|
|
tls_ctxStack.push(ctx);
|
2017-08-08 07:02:22 +05:30
|
|
|
tls_getPrimaryCtx = false;
|
|
|
|
|
} else {
|
2016-08-13 00:09:08 +05:30
|
|
|
e = hipErrorInvalidContext;
|
|
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetCurrent(hipCtx_t* ctx) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetCurrent, ctx);
|
2016-08-13 00:09:08 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2018-03-12 11:29:03 +05:30
|
|
|
if ((tls_getPrimaryCtx) || tls_ctxStack.empty()) {
|
2017-08-08 07:02:22 +05:30
|
|
|
*ctx = ihipGetTlsDefaultCtx();
|
|
|
|
|
} else {
|
2018-03-12 11:29:03 +05:30
|
|
|
*ctx = tls_ctxStack.top();
|
2016-08-26 19:03:23 +05:30
|
|
|
}
|
2016-08-13 00:09:08 +05:30
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxSetCurrent(hipCtx_t ctx) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxSetCurrent, ctx);
|
2016-08-13 00:09:08 +05:30
|
|
|
hipError_t e = hipSuccess;
|
2018-03-12 11:29:03 +05:30
|
|
|
if (ctx == NULL) {
|
2016-08-13 00:09:08 +05:30
|
|
|
tls_ctxStack.pop();
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
2016-08-13 00:09:08 +05:30
|
|
|
ihipSetTlsDefaultCtx(ctx);
|
|
|
|
|
tls_ctxStack.push(ctx);
|
2017-08-08 07:02:22 +05:30
|
|
|
tls_getPrimaryCtx = false;
|
2016-08-13 00:09:08 +05:30
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetDevice(hipDevice_t* device) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetDevice, device);
|
2016-08-13 01:17:46 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
ihipCtx_t* ctx = ihipGetTlsDefaultCtx();
|
2016-08-13 01:17:46 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
if (ctx == nullptr) {
|
2016-08-13 01:17:46 +05:30
|
|
|
e = hipErrorInvalidContext;
|
2016-12-17 16:53:03 +05:30
|
|
|
// TODO *device = nullptr;
|
2017-08-08 07:02:22 +05:30
|
|
|
} else {
|
2016-12-17 16:53:03 +05:30
|
|
|
auto deviceHandle = ctx->getDevice();
|
|
|
|
|
*device = deviceHandle->_deviceId;
|
2016-08-13 01:17:46 +05:30
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
2016-08-17 16:28:22 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetApiVersion(hipCtx_t ctx, int* apiVersion) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetApiVersion, apiVersion);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
|
|
|
|
if (apiVersion) {
|
|
|
|
|
*apiVersion = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(hipSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetCacheConfig(hipFuncCache_t* cacheConfig) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetCacheConfig, cacheConfig);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
|
|
|
|
*cacheConfig = hipFuncCachePreferNone;
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(hipSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxSetCacheConfig(hipFuncCache_t cacheConfig) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxSetCacheConfig, cacheConfig);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
|
|
|
|
// Nop, AMD does not support variable cache configs.
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(hipSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxSetSharedMemConfig(hipSharedMemConfig config) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxSetSharedMemConfig, config);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
|
|
|
|
// Nop, AMD does not support variable shared mem configs.
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(hipSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetSharedMemConfig(hipSharedMemConfig* pConfig) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetSharedMemConfig, pConfig);
|
2016-08-17 16:28:22 +05:30
|
|
|
|
|
|
|
|
*pConfig = hipSharedMemBankSizeFourByte;
|
|
|
|
|
|
|
|
|
|
return ihipLogStatus(hipSuccess);
|
2016-08-22 16:15:27 +05:30
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxSynchronize(void) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxSynchronize, 1);
|
2018-03-12 11:29:03 +05:30
|
|
|
return ihipLogStatus(ihipSynchronize()); // TODP Shall check validity of ctx?
|
2016-08-22 16:15:27 +05:30
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipCtxGetFlags(unsigned int* flags) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipCtxGetFlags, flags);
|
2016-08-22 16:15:27 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
ihipCtx_t* tempCtx;
|
|
|
|
|
tempCtx = ihipGetTlsDefaultCtx();
|
|
|
|
|
*flags = tempCtx->_ctxFlags;
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
2017-03-26 23:45:54 +05:30
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDevicePrimaryCtxGetState, dev, flags, active);
|
2017-03-26 23:45:54 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
auto deviceHandle = ihipGetDevice(dev);
|
|
|
|
|
|
|
|
|
|
if (deviceHandle == NULL) {
|
|
|
|
|
e = hipErrorInvalidDevice;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ihipCtx_t* tempCtx;
|
|
|
|
|
tempCtx = ihipGetTlsDefaultCtx();
|
|
|
|
|
ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx;
|
2018-03-12 11:29:03 +05:30
|
|
|
if (tempCtx == primaryCtx) {
|
2017-03-26 23:45:54 +05:30
|
|
|
*active = 1;
|
|
|
|
|
*flags = tempCtx->_ctxFlags;
|
2018-03-12 11:29:03 +05:30
|
|
|
} else {
|
|
|
|
|
*active = 0;
|
|
|
|
|
*flags = primaryCtx->_ctxFlags;
|
|
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
2017-03-26 23:45:54 +05:30
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDevicePrimaryCtxRelease, dev);
|
2017-03-26 23:45:54 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
auto deviceHandle = ihipGetDevice(dev);
|
|
|
|
|
|
|
|
|
|
if (deviceHandle == NULL) {
|
|
|
|
|
e = hipErrorInvalidDevice;
|
|
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDevicePrimaryCtxRetain, pctx, dev);
|
2017-03-26 23:45:54 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
auto deviceHandle = ihipGetDevice(dev);
|
|
|
|
|
|
|
|
|
|
if (deviceHandle == NULL) {
|
|
|
|
|
e = hipErrorInvalidDevice;
|
|
|
|
|
}
|
|
|
|
|
*pctx = deviceHandle->_primaryCtx;
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDevicePrimaryCtxReset, dev);
|
2017-03-26 23:45:54 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
auto deviceHandle = ihipGetDevice(dev);
|
|
|
|
|
|
|
|
|
|
if (deviceHandle == NULL) {
|
|
|
|
|
e = hipErrorInvalidDevice;
|
|
|
|
|
}
|
|
|
|
|
ihipCtx_t* primaryCtx = deviceHandle->_primaryCtx;
|
|
|
|
|
primaryCtx->locked_reset();
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-12 11:29:03 +05:30
|
|
|
hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) {
|
2018-11-08 08:36:50 -06:00
|
|
|
HIP_INIT_API(hipDevicePrimaryCtxSetFlags, dev, flags);
|
2017-03-26 23:45:54 +05:30
|
|
|
hipError_t e = hipSuccess;
|
|
|
|
|
auto deviceHandle = ihipGetDevice(dev);
|
|
|
|
|
|
|
|
|
|
if (deviceHandle == NULL) {
|
|
|
|
|
e = hipErrorInvalidDevice;
|
|
|
|
|
} else {
|
|
|
|
|
e = hipErrorContextAlreadyInUse;
|
|
|
|
|
}
|
|
|
|
|
return ihipLogStatus(e);
|
|
|
|
|
}
|