From 86e441c7697d88c73879637568f17ff2df17ec12 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 22 Sep 2016 15:21:23 +0530 Subject: [PATCH] Added hipRuntimeGetVersion function Change-Id: I59ec2beacb5a94439deed0dcc8eb37d6de1cc900 --- hipamd/include/hcc_detail/hip_runtime_api.h | 19 ++++++++++++++++ hipamd/include/nvcc_detail/hip_runtime_api.h | 5 +++++ hipamd/src/hip_context.cpp | 23 +++++++++++++++++--- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/hipamd/include/hcc_detail/hip_runtime_api.h b/hipamd/include/hcc_detail/hip_runtime_api.h index 8a2802e600..26c4f8ba32 100644 --- a/hipamd/include/hcc_detail/hip_runtime_api.h +++ b/hipamd/include/hcc_detail/hip_runtime_api.h @@ -1468,6 +1468,10 @@ hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device); /** * @brief Returns the approximate HIP driver version. + * + * @param [out] driverVersion + * + * @returns #hipSuccess, #hipErrorInavlidValue * * @warning The HIP feature set does not correspond to an exact CUDA SDK driver revision. * This function always set *driverVersion to 4 as an approximation though HIP supports @@ -1475,9 +1479,24 @@ hipError_t hipDeviceTotalMem (size_t *bytes,hipDevice_t device); * HIP apps code should not rely on the driver revision number here and should * use arch feature flags to test device capabilities or conditional compilation. * + * @see hipRuntimeGetVersion */ hipError_t hipDriverGetVersion(int *driverVersion) ; +/** + * @brief Returns the approximate HIP Runtime version. + * + * @param [out] runtimeVersion + * + * @returns #hipSuccess, #hipErrorInavlidValue + * + * @warning On HIP/HCC path this function returns HIP runtime patch version however on + * HIP/NVCC path this function return CUDA runtime version. + * + * @see hipDriverGetVersion + */ +hipError_t hipRuntimeGetVersion(int *runtimeVersion) ; + /** * @brief Loads code object from file into a hipModule_t * diff --git a/hipamd/include/nvcc_detail/hip_runtime_api.h b/hipamd/include/nvcc_detail/hip_runtime_api.h index c90c7cbf29..518c96ecd8 100644 --- a/hipamd/include/nvcc_detail/hip_runtime_api.h +++ b/hipamd/include/nvcc_detail/hip_runtime_api.h @@ -546,6 +546,11 @@ inline static hipError_t hipDriverGetVersion(int *driverVersion) return hipCUDAErrorTohipError(err); } +inline static hipError_t hipRuntimeGetVersion(int *runtimeVersion) +{ + return hipCUDAErrorTohipError(cudaRuntimeGetVersion(runtimeVersion)); +} + inline static hipError_t hipDeviceCanAccessPeer ( int* canAccessPeer, int device, int peerDevice ) { return hipCUDAErrorTohipError(cudaDeviceCanAccessPeer(canAccessPeer, device, peerDevice)); diff --git a/hipamd/src/hip_context.cpp b/hipamd/src/hip_context.cpp index dc0a30bd86..fa19f3a8a3 100644 --- a/hipamd/src/hip_context.cpp +++ b/hipamd/src/hip_context.cpp @@ -76,15 +76,32 @@ hipError_t hipDeviceGet(hipDevice_t *device, int deviceId) return ihipLogStatus(e); }; -hipError_t hipDriverGetVersion(int *driverVersion) +pError_t hipDriverGetVersion(int *driverVersion) { HIP_INIT_API(driverVersion); - + hipError_t e = hipSuccess; if (driverVersion) { *driverVersion = 4; } + else { + e = hipErrorInvalidValue; + } - return ihipLogStatus(hipSuccess); + return ihipLogStatus(e); +} + +hipError_t hipRuntimeGetVersion(int *runtimeVersion) +{ + HIP_INIT_API(runtimeVersion); + hipError_t e = hipSuccess; + if (runtimeVersion) { + *runtimeVersion = HIP_VERSION_PATCH; + } + else { + e = hipErrorInvalidValue; + } + + return ihipLogStatus(e); } hipError_t hipCtxDestroy(hipCtx_t ctx)