From 41cd5d6531bcfc75330e09abac1c538c108a44c5 Mon Sep 17 00:00:00 2001 From: "Kandula, Venkateshwar reddy" Date: Mon, 16 Jun 2025 16:09:13 -0500 Subject: [PATCH] [BUG FIX] [Counter Collection] SWDEV-523582- Use a map to differenciate xcc_sample_count wrt event id. (#99) * use a map to differenciate xcc_sample_count wrt event id. Change-Id: Ie1f2e8466edb244574686d49008125dc9f4e7efd * Format. Change-Id: I668c6ed448d8610d9d66f9cf77d0d27d7cf4e8b6 * use blockinfo to get xcc_sample_count. Change-Id: I066a10e3185df4c8767d4f8eae59aca1f78f5284 * use EventAttribDim for xcc_sample_count. Change-Id: Ide3707934b5b42c0462ea332b27f6e2e4fc0449f --------- Co-authored-by: Venkateshwar Reddy Kandula --- src/core/counters.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/counters.cpp b/src/core/counters.cpp index b0297754fc..395d0f1c0f 100644 --- a/src/core/counters.cpp +++ b/src/core/counters.cpp @@ -24,6 +24,7 @@ #include "core/include/aql_profile_v2.h" #include +#include #include #include #include @@ -129,6 +130,7 @@ hsa_status_t _internal_aqlprofile_pmc_iterate_data(aqlprofile_handle_t handle, aqlprofile_pmc_data_callback_t callback, void* userdata) { auto counter_memorymgr = MemoryManager::GetManager(handle.handle); + auto agent = counter_memorymgr->AgentHandle(); CounterMemoryManager* memorymgr = dynamic_cast(counter_memorymgr.get()); if (!memorymgr) return HSA_STATUS_ERROR_INVALID_ARGUMENT; @@ -159,7 +161,6 @@ hsa_status_t _internal_aqlprofile_pmc_iterate_data(aqlprofile_handle_t handle, if (status != HSA_STATUS_SUCCESS) return status; } - size_t xcc_sample_count = 0; for (uint32_t xcc_index = 0; xcc_index < xcc_num; xcc_index++) for (auto& event : events) { if (samples >= buffer_end_location) return HSA_STATUS_ERROR; @@ -168,12 +169,14 @@ hsa_status_t _internal_aqlprofile_pmc_iterate_data(aqlprofile_handle_t handle, // non-MI300A-AID counter event. uint32_t block_samples_count = pm4_factory->GetNumEvents(event.block_name); + const EventAttribDimension& attrib = EventAttribDimension::get(agent, event.block_name); + if (!attrib.get_num()) return HSA_STATUS_ERROR; + size_t xcc_sample_count = attrib.get_num_instances() * block_samples_count; for (uint32_t blk = 0; blk < block_samples_count; ++blk) { #if DEBUG_TRACE == 2 printf("DATA: xcc(%u) blk(%u) bloc id(%u) index(%u) counter id(%u) res(%lu)\n", xcc_index, blk, event.block_name, event.block_index, event.event_id, *samples); #endif - xcc_sample_count += xcc_index == 0; size_t xcc_sample_id = xcc_sample_count * xcc_index + static_cast(event.block_index) * block_samples_count + blk;