From 61583e3125eff1bb8da6e808e161389be17fc681 Mon Sep 17 00:00:00 2001 From: Venkateshwar Reddy Kandula Date: Tue, 9 Sep 2025 22:45:05 -0500 Subject: [PATCH] [AQLProfile] Fix caching of agents with new available data (#752) * > hsa_agent not provided by new api/rocprofiler-sdk and causes every device to have same id, in cases where gfxip is same and config is different pm4factory doesn't know the difference. This fix uses gfxip and CU count as a key for cache. * Change comparison from gfxip to name in instances_fncomp_t Updated comparison in instances_fncomp_t to use 'name' for backward compatibility with rocprofv2. --------- Co-authored-by: Venkateshwar Reddy Kandula --- projects/aqlprofile/src/core/pm4_factory.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/projects/aqlprofile/src/core/pm4_factory.h b/projects/aqlprofile/src/core/pm4_factory.h index 386abe3495..70deaaffce 100644 --- a/projects/aqlprofile/src/core/pm4_factory.h +++ b/projects/aqlprofile/src/core/pm4_factory.h @@ -256,11 +256,17 @@ class Pm4Factory { private: // PM4 factory instance map type struct instances_fncomp_t { - bool operator()(const hsa_agent_t& a, const hsa_agent_t& b) const { - return a.handle < b.handle; + bool operator()(const AgentInfo& a, const AgentInfo& b) const { + // using name instead of gfxip due to backward compatability with rocprofv2, + // as in newer api which rocprofv3 uses both name and gfxip strings are same for a agent. + int cmp = strcmp(a.name, b.name); + if (cmp < 0) return true; + if (cmp > 0) return false; + // If gfxip strings are equal, compare cu_num + return a.cu_num < b.cu_num; } }; - typedef std::map instances_t; + typedef std::map instances_t; // Create GFX9 generic factory static Pm4Factory* Gfx9Create(const AgentInfo* agent_info); @@ -295,7 +301,7 @@ inline Pm4Factory* Pm4Factory::Create(const AgentInfo* agent_info, gpu_id_t gpu_ bool concurrent) { // Check if we have the instance already created if (instances_ == NULL) instances_ = new instances_t; - const auto ret = instances_->insert({agent_info->dev_id, NULL}); + const auto ret = instances_->insert({*agent_info, NULL}); instances_t::iterator it = ret.first; concurrent_create_mode_ = concurrent;