From d2b35dfee6c30b2f707b87bef44e9bfe08a0bbbe Mon Sep 17 00:00:00 2001 From: Sunday Clement Date: Fri, 20 Jun 2025 11:26:04 -0400 Subject: [PATCH] rocrtst: Add new test for querying Clock Counters added new subtest to Agent Properties test, to check functionality of query. Signed-off-by: Sunday Clement --- rocrtst/suites/functional/agent_props.cc | 47 +++++++++++++++++++++++- rocrtst/suites/functional/agent_props.h | 3 ++ rocrtst/suites/test_common/main.cc | 3 +- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/rocrtst/suites/functional/agent_props.cc b/rocrtst/suites/functional/agent_props.cc index 3342d048f9..8c662f0c1f 100644 --- a/rocrtst/suites/functional/agent_props.cc +++ b/rocrtst/suites/functional/agent_props.cc @@ -161,9 +161,32 @@ void AgentPropTest::QueryAgentProp(hsa_agent_t agent, propList_.push_back(ss.str()); break; } - default: - FAIL(); + case HSA_AMD_AGENT_INFO_CLOCK_COUNTERS: { + std::stringstream str_s; + + hsa_amd_clock_counters_t counters = {0}; + + err = hsa_agent_get_info(agent, prop, &counters); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + str_s << "\n\n Clock Counters"; + str_s << "\n Clock Frequency: " << counters.system_clock_frequency << "\n"; + str_s << " GPU Clock counter: " << counters.gpu_clock_counter << "\n"; + str_s << " System system_clock_counter: " << counters.system_clock_counter << "\n"; + str_s << " CPU Clock counter: " << counters.cpu_clock_counter << "\n"; + propList_.push_back(str_s.str()); + + ASSERT_NE(0, counters.system_clock_frequency); + ASSERT_NE(0, counters.gpu_clock_counter); + ASSERT_NE(0, counters.system_clock_counter); + ASSERT_NE(0, counters.cpu_clock_counter); + + break; } + default: + FAIL(); + } + } void AgentPropTest::QueryAgentUUID() { @@ -195,4 +218,24 @@ void AgentPropTest::QueryAgentUUID() { } } +void AgentPropTest::QueryAgentClockCounters() { + hsa_status_t err; + if (verbosity() > 0) { + PrintAgentPropsSubtestHeader("Query Agent's Clock Counters"); + } + + // find all gpu agents + std::vector gpus; + err = hsa_iterate_agents(rocrtst::IterateGPUAgents, &gpus); + ASSERT_EQ(err, HSA_STATUS_SUCCESS); + + for (uint32_t idx = 0 ; idx < gpus.size(); ++idx) { + QueryAgentProp(gpus[idx], (hsa_agent_info_t)HSA_AMD_AGENT_INFO_CLOCK_COUNTERS); + } + + if (verbosity() > 0) { + std::cout << " *** Execution completed - subtest Passed " << " ***" << std::endl; + } +} + #undef RET_IF_HSA_ERR diff --git a/rocrtst/suites/functional/agent_props.h b/rocrtst/suites/functional/agent_props.h index a8bd1a4f81..def46f8a07 100644 --- a/rocrtst/suites/functional/agent_props.h +++ b/rocrtst/suites/functional/agent_props.h @@ -77,6 +77,9 @@ class AgentPropTest : public TestBase { // @Brief: Query UUID property of agents of a ROCm platform void QueryAgentUUID(); + // @Brief: Query Clock Counter property of agents of a ROCm platform + void QueryAgentClockCounters(); + private: // Capture value for all agents on system std::vector propList_; diff --git a/rocrtst/suites/test_common/main.cc b/rocrtst/suites/test_common/main.cc index 4ba353e969..42e3a6f58a 100644 --- a/rocrtst/suites/test_common/main.cc +++ b/rocrtst/suites/test_common/main.cc @@ -374,10 +374,11 @@ TEST(rocrtstFunc, Deallocation_Notifier_Test) { RunGenericTest(¬ifier); } -TEST(rocrtstFunc, AgentProp_UUID) { +TEST(rocrtstFunc, AgentPropertiesTests) { AgentPropTest propTest; RunCustomTestProlog(&propTest); propTest.QueryAgentUUID(); + propTest.QueryAgentClockCounters(); RunCustomTestEpilog(&propTest); }