Implementation of hipCtxGetDevice
Change-Id: I067572e486323c3aad6f744a2c0c4997c8696af6
This commit is contained in:
@@ -1063,6 +1063,7 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx);
|
|||||||
|
|
||||||
hipError_t hipCtxGetCurrent(hipCtx_t* ctx);
|
hipError_t hipCtxGetCurrent(hipCtx_t* ctx);
|
||||||
|
|
||||||
|
hipError_t hipCtxGetDevice(hipDevice_t *device);
|
||||||
|
|
||||||
// TODO-ctx
|
// TODO-ctx
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -152,3 +152,17 @@ hipError_t hipCtxSetCurrent(hipCtx_t ctx)
|
|||||||
return ihipLogStatus(e);
|
return ihipLogStatus(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hipError_t hipCtxGetDevice(hipDevice_t *device)
|
||||||
|
{
|
||||||
|
hipError_t e = hipSuccess;
|
||||||
|
|
||||||
|
ihipCtx_t *ctx = ihipGetTlsDefaultCtx();
|
||||||
|
|
||||||
|
if(ctx == nullptr) {
|
||||||
|
e = hipErrorInvalidContext;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*device = (ihipDevice_t*)ctx->getDevice();
|
||||||
|
}
|
||||||
|
return ihipLogStatus(e);
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,13 +30,14 @@ int main(int argc, char *argv[])
|
|||||||
HIPCHECK(hipInit(0));
|
HIPCHECK(hipInit(0));
|
||||||
|
|
||||||
hipDevice_t device;
|
hipDevice_t device;
|
||||||
|
hipDevice_t device1;
|
||||||
hipCtx_t ctx;
|
hipCtx_t ctx;
|
||||||
hipCtx_t ctx1;
|
hipCtx_t ctx1;
|
||||||
|
|
||||||
HIPCHECK(hipDeviceGetFromId(&device, 0));
|
HIPCHECK(hipDeviceGetFromId(&device, 0));
|
||||||
HIPCHECK(hipCtxCreate(&ctx, 0, device));
|
HIPCHECK(hipCtxCreate(&ctx, 0, device));
|
||||||
HIPCHECK(hipCtxGetCurrent(&ctx1));
|
HIPCHECK(hipCtxGetCurrent(&ctx1));
|
||||||
|
HIPCHECK(hipCtxGetDevice(&device1));
|
||||||
HIPCHECK(hipCtxPopCurrent(&ctx1));
|
HIPCHECK(hipCtxPopCurrent(&ctx1));
|
||||||
HIPCHECK(hipCtxGetCurrent(&ctx1));
|
HIPCHECK(hipCtxGetCurrent(&ctx1));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user