From 143f84fe6be83781bfc4328dfc5079bf031f31aa Mon Sep 17 00:00:00 2001 From: "Kandula, Venkateshwar reddy" Date: Tue, 11 Feb 2025 13:05:57 -0600 Subject: [PATCH] [BUG FIX] store dimensions in counter id when used reduce operator (#181) * save other dimension in counter id. * Formating --------- Co-authored-by: Venkateshwar Reddy Kandula --- .../rocprofiler-sdk/counters/evaluate_ast.cpp | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp b/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp index 69f6f75a39..a9301fd5a6 100644 --- a/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp +++ b/source/lib/rocprofiler-sdk/counters/evaluate_ast.cpp @@ -89,21 +89,22 @@ perform_reduction_to_single_instance(ReduceOperation case REDUCE_SUM: [[fallthrough]]; case REDUCE_AVG: { - *result = std::accumulate(input_array->begin(), - input_array->end(), - rocprofiler_record_counter_t{.id = 0, - .counter_value = 0, - .dispatch_id = 0, - .user_data = {.value = 0}, - .agent_id = {.handle = 0}}, - [](auto& a, auto& b) { - return rocprofiler_record_counter_t{ - .id = a.id, - .counter_value = a.counter_value + b.counter_value, - .dispatch_id = a.dispatch_id, - .user_data = {.value = 0}, - .agent_id = {.handle = 0}}; - }); + *result = std::accumulate( + input_array->begin(), + input_array->end(), + rocprofiler_record_counter_t{.id = input_array->begin()->id, + .counter_value = 0, + .dispatch_id = input_array->begin()->dispatch_id, + .user_data = input_array->begin()->user_data, + .agent_id = input_array->begin()->agent_id}, + [](auto& a, auto& b) { + return rocprofiler_record_counter_t{ + .id = a.id, + .counter_value = a.counter_value + b.counter_value, + .dispatch_id = a.dispatch_id, + .user_data = a.user_data, + .agent_id = a.agent_id}; + }); if(reduce_op == REDUCE_AVG) { (*result).counter_value /= input_array->size(); @@ -127,7 +128,7 @@ perform_reduction( .counter_value = 0, .dispatch_id = 0, .user_data = {.value = 0}, - .agent_id = {.handle = 0}}; + .agent_id = input_array->begin()->agent_id}; perform_reduction_to_single_instance(reduce_op, input_array, &result); input_array->clear(); input_array->push_back(result);