Skip to content

Commit 41cd5d6

Browse files
authored
[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 <vkandula@amd.com>
1 parent d046917 commit 41cd5d6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/core/counters.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "core/include/aql_profile_v2.h"
2525

2626
#include <array>
27+
#include <cstddef>
2728
#include <cstdint>
2829
#include <future>
2930
#include <map>
@@ -129,6 +130,7 @@ hsa_status_t _internal_aqlprofile_pmc_iterate_data(aqlprofile_handle_t handle,
129130
aqlprofile_pmc_data_callback_t callback,
130131
void* userdata) {
131132
auto counter_memorymgr = MemoryManager::GetManager(handle.handle);
133+
auto agent = counter_memorymgr->AgentHandle();
132134
CounterMemoryManager* memorymgr = dynamic_cast<CounterMemoryManager*>(counter_memorymgr.get());
133135
if (!memorymgr) return HSA_STATUS_ERROR_INVALID_ARGUMENT;
134136

@@ -159,7 +161,6 @@ hsa_status_t _internal_aqlprofile_pmc_iterate_data(aqlprofile_handle_t handle,
159161
if (status != HSA_STATUS_SUCCESS) return status;
160162
}
161163

162-
size_t xcc_sample_count = 0;
163164
for (uint32_t xcc_index = 0; xcc_index < xcc_num; xcc_index++)
164165
for (auto& event : events) {
165166
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,
168169

169170
// non-MI300A-AID counter event.
170171
uint32_t block_samples_count = pm4_factory->GetNumEvents(event.block_name);
172+
const EventAttribDimension& attrib = EventAttribDimension::get(agent, event.block_name);
173+
if (!attrib.get_num()) return HSA_STATUS_ERROR;
174+
size_t xcc_sample_count = attrib.get_num_instances() * block_samples_count;
171175
for (uint32_t blk = 0; blk < block_samples_count; ++blk) {
172176
#if DEBUG_TRACE == 2
173177
printf("DATA: xcc(%u) blk(%u) bloc id(%u) index(%u) counter id(%u) res(%lu)\n", xcc_index,
174178
blk, event.block_name, event.block_index, event.event_id, *samples);
175179
#endif
176-
xcc_sample_count += xcc_index == 0;
177180
size_t xcc_sample_id = xcc_sample_count * xcc_index +
178181
static_cast<size_t>(event.block_index) * block_samples_count + blk;
179182

0 commit comments

Comments
 (0)