From e53c7c63c04fa16973e8c9f02259ce284aa271f7 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Fri, 12 Oct 2018 19:13:09 -0500 Subject: [PATCH] aqlprofile extension version check Change-Id: If824764f199eca15a0341cdf6177d8d6353e29f3 [ROCm/ROCR-Runtime commit: d788a5397282ccf72b153085c7526af0389660c7] --- .../runtime/hsa-runtime/core/runtime/hsa.cpp | 17 ++++++++++++++++- .../hsa-runtime/inc/hsa_ven_amd_aqlprofile.h | 7 ++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp index 3444bceddf..0969d27e32 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -467,6 +467,8 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v if (extension == HSA_EXTENSION_AMD_AQLPROFILE) { if (version_major != hsa_ven_amd_aqlprofile_VERSION_MAJOR) { + debug_print("aqlprofile API incompatible ver %d, current ver %d\n", + version_major, hsa_ven_amd_aqlprofile_VERSION_MAJOR); return HSA_STATUS_ERROR; } @@ -476,7 +478,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v return HSA_STATUS_ERROR; } - hsa_ven_amd_aqlprofile_1_00_pfn_t ext_table; + hsa_ven_amd_aqlprofile_pfn_t ext_table; ext_table.hsa_ven_amd_aqlprofile_version_major = (decltype(::hsa_ven_amd_aqlprofile_version_major)*) os::GetExportAddress(lib, "hsa_ven_amd_aqlprofile_version_major"); @@ -508,6 +510,19 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v (decltype(::hsa_ven_amd_aqlprofile_iterate_data)*) os::GetExportAddress(lib, "hsa_ven_amd_aqlprofile_iterate_data"); + bool version_incompatible = true; + uint32_t version_curr = 0; + version_major = HSA_AQLPROFILE_VERSION_MAJOR; + if (ext_table.hsa_ven_amd_aqlprofile_version_major != NULL) { + version_curr = ext_table.hsa_ven_amd_aqlprofile_version_major(); + version_incompatible = (version_major != version_curr); + } + if (version_incompatible == true) { + debug_print("Loading '%s' failed, incompatible ver %d, current ver %d\n", + kAqlProfileLib, version_major, version_curr); + return HSA_STATUS_ERROR; + } + memcpy(table, &ext_table, Min(sizeof(ext_table), table_length)); return HSA_STATUS_SUCCESS; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_aqlprofile.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_aqlprofile.h index 96523092d2..1f771515d0 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_aqlprofile.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ven_amd_aqlprofile.h @@ -292,12 +292,13 @@ hsa_status_t hsa_ven_amd_aqlprofile_error_string( /** * @brief Extension version. */ -#define hsa_ven_amd_aqlprofile 001000 #define hsa_ven_amd_aqlprofile_VERSION_MAJOR 1 +#define hsa_ven_amd_aqlprofile_LIB(suff) "libhsa-amd-aqlprofile" suff ".so" + #ifdef HSA_LARGE_MODEL -static const char kAqlProfileLib[] = "libhsa-amd-aqlprofile64.so.1"; +static const char kAqlProfileLib[] = hsa_ven_amd_aqlprofile_LIB("64"); #else -static const char kAqlProfileLib[] = "libhsa-amd-aqlprofile.so.1"; +static const char kAqlProfileLib[] = hsa_ven_amd_aqlprofile_LIB(""); #endif /**