SWDEV-515574: Cache Number_Node static value. (#217)

* Cache Number_Node static value. To avoid value overwriting in consecutive dispatch callbacks.

* Format.

* tests for number_node evaluate.

---------

Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com>
This commit is contained in:
Kandula, Venkateshwar reddy
2025-02-19 19:10:16 -06:00
committed by GitHub
parent b4b81f9095
commit 5cb4ad449f
2 changed files with 27 additions and 3 deletions
@@ -767,7 +767,12 @@ EvaluateAST::evaluate(
case NONE:
case CONSTANT_NODE:
case RANGE_NODE: break;
case NUMBER_NODE: return &_static_value;
case NUMBER_NODE:
{
cache.emplace_back(std::make_unique<std::vector<rocprofiler_record_counter_t>>());
*cache.back() = _static_value;
return cache.back().get();
}
case ADDITION_NODE:
return perform_op([](auto& a, auto& b) {
return rocprofiler_record_counter_t{
@@ -1054,8 +1054,9 @@ TEST(evaluate_ast, evaluate_mixed_counters)
Metric("gfx9", "BATES", "a", "a", "a", "MAX_WAVE_SIZE*reduce(VOORHEES,sum)", "", 6)},
{"KRAMER", Metric("gfx9", "KRAMER", "a", "a", "a", "reduce(KRUEGER,sum)*SE_NUM", "", 7)},
{"TORRANCE",
Metric("gfx9", "TORRANCE", "a", "a", "a", "reduce(KRUEGER,sum)*SIMD_NUM", "", 8)}};
add_constants(metrics, 9);
Metric("gfx9", "TORRANCE", "a", "a", "a", "reduce(KRUEGER,sum)*SIMD_NUM", "", 8)},
{"DODGE", Metric("gfx9", "DODGE", "a", "a", "a", "10*TORRANCE", "", 9)}};
add_constants(metrics, 10);
std::unordered_map<std::string, std::vector<rocprofiler_record_counter_t>> base_counter_data = {
{"VOORHEES", construct_test_data_dim(get_base_rec_id(0), {ROCPROFILER_DIMENSION_NONE}, 8)},
@@ -1088,6 +1089,24 @@ TEST(evaluate_ast, evaluate_mixed_counters)
.user_data = {.value = 0},
.agent_id = {.handle = 0}}}),
2},
{"DODGE",
times_vec(sum_vec(base_counter_data["KRUEGER"]),
std::vector<rocprofiler_record_counter_t>{{.id = 0,
.counter_value = 6240,
.dispatch_id = 0,
.user_data = {.value = 0},
.agent_id = {.handle = 0}}}),
2},
{"DODGE",
times_vec(sum_vec(base_counter_data["KRUEGER"]),
std::vector<rocprofiler_record_counter_t>{{.id = 0,
.counter_value = 6240,
.dispatch_id = 0,
.user_data = {.value = 0},
.agent_id = {.handle = 0}}}),
2},
};
std::unordered_map<std::string, std::unordered_map<std::string, EvaluateAST>> asts;