From cd496a5a907c19d365280c85289008cde53bf11a Mon Sep 17 00:00:00 2001
From: foreman
Date: Sat, 3 Aug 2019 12:23:25 -0400
Subject: [PATCH] P4 to Git Change 1978068 by cpaquot@cpaquot-ocl-lc-lnx on
2019/08/03 12:16:57
SWDEV-198546 - [HIP] Implemented basic Ctx APIs that are deprecated.
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_context.cpp#20 edit
[ROCm/hip commit: 44813761ba24569f8532e18498ff1821cb2bcf85]
---
projects/hip/api/hip/hip_context.cpp | 43 ++++++++++++++++++++--------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/projects/hip/api/hip/hip_context.cpp b/projects/hip/api/hip/hip_context.cpp
index d519370971..d2c37c1b13 100644
--- a/projects/hip/api/hip/hip_context.cpp
+++ b/projects/hip/api/hip/hip_context.cpp
@@ -309,39 +309,58 @@ hipError_t hipCtxGetFlags(unsigned int* flags) {
hipError_t hipDevicePrimaryCtxGetState(hipDevice_t dev, unsigned int* flags, int* active) {
HIP_INIT_API(dev, flags, active);
- assert(0 && "Unimplemented");
+ if (static_cast(dev) >= g_devices.size()) {
+ HIP_RETURN(hipErrorInvalidDevice);
+ }
- HIP_RETURN(hipErrorUnknown);
+ if (flags != nullptr) {
+ *flags = 0;
+ }
+
+ if (active != nullptr) {
+ *active = (g_devices[dev] == hip::getCurrentContext())? 1 : 0;
+ }
+
+ HIP_RETURN(hipSuccess);
}
hipError_t hipDevicePrimaryCtxRelease(hipDevice_t dev) {
HIP_INIT_API(dev);
- assert(0 && "Unimplemented");
+ if (static_cast(dev) >= g_devices.size()) {
+ HIP_RETURN(hipErrorInvalidDevice);
+ }
- HIP_RETURN(hipErrorUnknown);
+ HIP_RETURN(hipSuccess);
}
hipError_t hipDevicePrimaryCtxRetain(hipCtx_t* pctx, hipDevice_t dev) {
HIP_INIT_API(pctx, dev);
- assert(0 && "Unimplemented");
+ if (static_cast(dev) >= g_devices.size()) {
+ HIP_RETURN(hipErrorInvalidDevice);
+ }
+ if (pctx == nullptr) {
+ HIP_RETURN(hipErrorInvalidValue);
+ }
- HIP_RETURN(hipErrorUnknown);
+ *pctx = reinterpret_cast(g_devices[dev]);
+
+ HIP_RETURN(hipSuccess);
}
hipError_t hipDevicePrimaryCtxReset(hipDevice_t dev) {
HIP_INIT_API(dev);
- assert(0 && "Unimplemented");
-
- HIP_RETURN(hipErrorUnknown);
+ HIP_RETURN(hipSuccess);
}
hipError_t hipDevicePrimaryCtxSetFlags(hipDevice_t dev, unsigned int flags) {
HIP_INIT_API(dev, flags);
- assert(0 && "Unimplemented");
-
- HIP_RETURN(hipErrorUnknown);
+ if (static_cast(dev) >= g_devices.size()) {
+ HIP_RETURN(hipErrorInvalidDevice);
+ } else {
+ HIP_RETURN(hipErrorContextAlreadyInUse);
+ }
}