From 7cac13e36ef321512fba79889f1396b682fbd0ee Mon Sep 17 00:00:00 2001 From: anusha GodavarthySurya Date: Thu, 25 Nov 2021 00:33:26 -0800 Subject: [PATCH] SWDEV-305766 - Added new debug APIs to get build information Change-Id: Ibbf0c010cd8f7e6e659f2c4ba932cc8436574431 [ROCm/clr commit: e90cb3b07b176aa6a0547dcd8198a850311b88f3] --- projects/clr/hipamd/CMakeLists.txt | 6 +++- .../include/hip/amd_detail/amd_hip_runtime.h | 36 +++++++++++++++++++ projects/clr/hipamd/src/amdhip.def | 3 ++ projects/clr/hipamd/src/hip_global.cpp | 13 +++++++ projects/clr/hipamd/src/hip_hcc.def.in | 3 ++ projects/clr/hipamd/src/hip_hcc.map.in | 3 ++ 6 files changed, 63 insertions(+), 1 deletion(-) diff --git a/projects/clr/hipamd/CMakeLists.txt b/projects/clr/hipamd/CMakeLists.txt index e49dbf9e53..e6a3277595 100755 --- a/projects/clr/hipamd/CMakeLists.txt +++ b/projects/clr/hipamd/CMakeLists.txt @@ -124,6 +124,8 @@ if(GIT_FOUND) set(HIP_VERSION_GITHASH ${git_output}) endif() + set(HIP_VERSION_BUILD_ID 0) + set(HIP_VERSION_BUILD_NAME "") if(NOT DEFINED ENV{HIP_OFFICIAL_BUILD} AND NOT HIP_OFFICIAL_BUILD) set(HIP_VERSION_PATCH ${HIP_VERSION_GITDATE}) endif() @@ -284,7 +286,9 @@ set(_versionInfoHeader #define HIP_VERSION_MAJOR ${HIP_VERSION_MAJOR} #define HIP_VERSION_MINOR ${HIP_VERSION_MINOR} #define HIP_VERSION_PATCH ${HIP_VERSION_PATCH} -#define HIP_VERSION_GITHASH ${HIP_VERSION_GITHASH} +#define HIP_VERSION_GITHASH \"${HIP_VERSION_GITHASH}\" +#define HIP_VERSION_BUILD_ID ${HIP_VERSION_BUILD_ID} +#define HIP_VERSION_BUILD_NAME \"${HIP_VERSION_BUILD_NAME}\" #define HIP_VERSION (HIP_VERSION_MAJOR * 10000000 + HIP_VERSION_MINOR * 100000 + HIP_VERSION_PATCH)\n #define __HIP_HAS_GET_PCH ${_pchStatus}\n #endif\n diff --git a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_runtime.h b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_runtime.h index dd427ebd9d..41cdf24ea0 100644 --- a/projects/clr/hipamd/include/hip/amd_detail/amd_hip_runtime.h +++ b/projects/clr/hipamd/include/hip/amd_detail/amd_hip_runtime.h @@ -31,6 +31,42 @@ THE SOFTWARE. #include +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Query the installed library build name. + * + * This function can be used even when the library is not initialized. + * + * @returns Returns a string describing the build version of the library. The + * string is owned by the library. + */ +const char* amd_dbgapi_get_build_name(); + +/** + * @brief Query the installed library git hash. + * + * This function can be used even when the library is not initialized. + * + * @returns Returns git hash of the library. + */ +const char* amd_dbgapi_get_git_hash(); + +/** + * @brief Query the installed library build ID. + * + * This function can be used even when the library is not initialized. + * + * @returns Returns build ID of the library. + */ +size_t amd_dbgapi_get_build_id(); + +#ifdef __cplusplus +} /* extern "c" */ +#endif + //--- // Top part of file can be compiled with any compiler diff --git a/projects/clr/hipamd/src/amdhip.def b/projects/clr/hipamd/src/amdhip.def index 4f58c0562e..659fe57c97 100644 --- a/projects/clr/hipamd/src/amdhip.def +++ b/projects/clr/hipamd/src/amdhip.def @@ -347,3 +347,6 @@ hipGraphExecHostNodeSetParams hipGraphExecUpdate hipGraphInstantiateWithFlags hipGraphExecMemsetNodeSetParams +amd_dbgapi_get_build_name +amd_dbgapi_get_git_hash +amd_dbgapi_get_build_id diff --git a/projects/clr/hipamd/src/hip_global.cpp b/projects/clr/hipamd/src/hip_global.cpp index 6093df1842..b6c05523dd 100644 --- a/projects/clr/hipamd/src/hip_global.cpp +++ b/projects/clr/hipamd/src/hip_global.cpp @@ -4,6 +4,19 @@ #include "hip_internal.hpp" #include "hip_code_object.hpp" #include "platform/program.hpp" +#include + +const char* amd_dbgapi_get_build_name(void) { + return HIP_VERSION_BUILD_NAME; +} + +const char* amd_dbgapi_get_git_hash() { + return HIP_VERSION_GITHASH; +} + +size_t amd_dbgapi_get_build_id() { + return HIP_VERSION_BUILD_ID; +} #ifdef __HIP_ENABLE_PCH extern const char __hip_pch[]; diff --git a/projects/clr/hipamd/src/hip_hcc.def.in b/projects/clr/hipamd/src/hip_hcc.def.in index bb0c794215..c6bda1aa79 100644 --- a/projects/clr/hipamd/src/hip_hcc.def.in +++ b/projects/clr/hipamd/src/hip_hcc.def.in @@ -345,3 +345,6 @@ hipGraphExecHostNodeSetParams hipGraphExecUpdate hipGraphInstantiateWithFlags hipGraphExecMemsetNodeSetParams +amd_dbgapi_get_build_name +amd_dbgapi_get_git_hash +amd_dbgapi_get_build_id diff --git a/projects/clr/hipamd/src/hip_hcc.map.in b/projects/clr/hipamd/src/hip_hcc.map.in index fe3393dd96..bf43f4386d 100644 --- a/projects/clr/hipamd/src/hip_hcc.map.in +++ b/projects/clr/hipamd/src/hip_hcc.map.in @@ -377,6 +377,9 @@ global: hipGraphExecUpdate; hipGraphInstantiateWithFlags; hipGraphExecMemsetNodeSetParams; + amd_dbgapi_get_build_name; + amd_dbgapi_get_git_hash; + amd_dbgapi_get_build_id; local: *; } hip_4.4;