Skip to content

Commit 66f0df4

Browse files
venkat1361venky1306Copilot
authored
[rocprofiler-sdk][Tests] add counter dimensions instance tests for rocprofiler_counter_info_v1_t API change (#637)
* Initial commit, counter dimensions tests, public API. * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * add comments. * Format. * Format. --------- Co-authored-by: Venkateshwar Reddy Kandula <venkateshwar.kandula1306@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1a39135 commit 66f0df4

File tree

1 file changed

+36
-0
lines changed
  • projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests

1 file changed

+36
-0
lines changed

projects/rocprofiler-sdk/source/lib/rocprofiler-sdk/counters/tests/metrics_test.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,5 +275,41 @@ TEST(metrics, check_public_api_query)
275275
ASSERT_EQ(dim_permutations.insert(dim_ids).second, true);
276276
}
277277
ASSERT_EQ(instance_count, dim_permutations.size());
278+
279+
// Iterate over all dimensions available for this metric. Ex: XCC, SE, SA, Instances.
280+
for(size_t i = 0; i < info.dimensions_count; i++)
281+
{
282+
// Current dimension size, like SE[0:6] has size of 7.
283+
size_t current_dimension_size = info.dimensions[i]->instance_size;
284+
ASSERT_NE(info.dimensions[i]->name, nullptr);
285+
std::string current_dimension_name(info.dimensions[i]->name);
286+
287+
// Used to store index wise count (like number of instances with SE[0], SE[1], etc.) to
288+
// validate permutations included in dimensions_instances
289+
auto index_to_count = std::map<int, int>{};
290+
291+
// Iterate over all instances with unique dimensions indexes.
292+
for(size_t j = 0; j < info.dimensions_instances_count; j++)
293+
{
294+
size_t dimension_size = info.dimensions_instances[j]->dimensions_count;
295+
296+
for(size_t k = 0; k < dimension_size; k++)
297+
{
298+
// Let's say for a metric has XCC[0:7], SE[0:6], Instances[0:10]
299+
// Total Instances count: 8*7*11
300+
if(std::string_view(
301+
info.dimensions_instances[j]->dimensions[k]->dimension_name) ==
302+
current_dimension_name)
303+
index_to_count[info.dimensions_instances[j]->dimensions[k]->index]++;
304+
}
305+
}
306+
for(auto pr : index_to_count)
307+
{
308+
// Ex: Check there are (8*7*11)/8 counter samples with XCC=0.
309+
ASSERT_EQ(pr.second, info.dimensions_instances_count / current_dimension_size);
310+
}
311+
// Ex: Maximum index of XCC doesn't exceed or be equal to 8.
312+
ASSERT_EQ(index_to_count.rbegin()->first + 1, current_dimension_size);
313+
}
278314
}
279315
}

0 commit comments

Comments
 (0)