From fd99b74287ebbefc4063e822bbab93f5deb0f021 Mon Sep 17 00:00:00 2001 From: Chris Freehill Date: Tue, 22 Oct 2024 18:09:03 -0500 Subject: [PATCH] rocr: supported_isas map elements should persist The supported_isas static unordered_map was adding stack allocated Isa objects. Instead, make the objects statically allocated, as supported_isas itself is. Change-Id: I23405e218290d48deea6f984f76c57e7b43e314e --- runtime/hsa-runtime/core/inc/isa.h | 2 +- runtime/hsa-runtime/core/runtime/isa.cpp | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/runtime/hsa-runtime/core/inc/isa.h b/runtime/hsa-runtime/core/inc/isa.h index a04c86e19f..3bfef30208 100644 --- a/runtime/hsa-runtime/core/inc/isa.h +++ b/runtime/hsa-runtime/core/inc/isa.h @@ -226,7 +226,7 @@ class IsaRegistry final { private: /// @brief IsaRegistry's map type. - typedef std::unordered_map IsaMap; + typedef std::unordered_map> IsaMap; /// @brief Default constructor IsaRegistry() = delete; diff --git a/runtime/hsa-runtime/core/runtime/isa.cpp b/runtime/hsa-runtime/core/runtime/isa.cpp index 140802e10c..984b32e5e6 100755 --- a/runtime/hsa-runtime/core/runtime/isa.cpp +++ b/runtime/hsa-runtime/core/runtime/isa.cpp @@ -201,21 +201,21 @@ hsa_round_method_t Isa::GetRoundMethod( const Isa *IsaRegistry::GetIsa(const std::string &full_name) { auto isareg_iter = GetSupportedIsas().find(full_name); return isareg_iter == GetSupportedIsas().end() ? - nullptr : &isareg_iter->second; + nullptr : &isareg_iter->second.get(); } const Isa *IsaRegistry::GetIsa(const Isa::Version &version, IsaFeature sramecc, IsaFeature xnack) { auto isareg_iter = std::find_if(GetSupportedIsas().begin(), GetSupportedIsas().end(), [&](const IsaMap::value_type& isareg) { - return isareg.second.GetVersion() == version && - (isareg.second.GetSramecc() == IsaFeature::Unsupported || - isareg.second.GetSramecc() == sramecc) && - (isareg.second.GetXnack() == IsaFeature::Unsupported || - isareg.second.GetXnack() == xnack); + return isareg.second.get().GetVersion() == version && + (isareg.second.get().GetSramecc() == IsaFeature::Unsupported || + isareg.second.get().GetSramecc() == sramecc) && + (isareg.second.get().GetXnack() == IsaFeature::Unsupported || + isareg.second.get().GetXnack() == xnack); }); return isareg_iter == GetSupportedIsas().end() ? - nullptr : &isareg_iter->second; + nullptr : &isareg_iter->second.get(); } @@ -227,7 +227,7 @@ constexpr size_t hsa_name_size = 63; // FIXME: Use static_assert when C++17 used. #define ISAREG_ENTRY_GEN(name, maj, min, stp, sramecc, xnack, wavefrontsize) \ assert(std::char_traits::length(name) <= hsa_name_size); \ - Isa amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize; \ + static Isa amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize; \ amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize.targetid_ = name; \ amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize.version_ = Isa::Version(maj, min, stp); \ amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize.sramecc_ = sramecc; \ @@ -235,7 +235,7 @@ constexpr size_t hsa_name_size = 63; amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize.wavefront_.num_threads_ = wavefrontsize; \ supported_isas.insert(std::make_pair( \ amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize.GetIsaName(), \ - amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize)); \ + std::ref(amd_amdgpu_##maj##min##stp##_SRAMECC_##sramecc##_XNACK_##xnack##_WAVEFRONTSIZE_##wavefrontsize))); \ static IsaMap supported_isas;