[SWDEV-518071] Return HSA not loaded status (device counter collection) (#242)
* [SWDEV-518071] Return HSA not loaded status (device counter collection) This is a state that a caller would want to know about to understand if they got no counters because of a failure or if they were trying to collect counters too early (as is the case in the sample, which can attempt to collect counters before HSA is inited). * Minor edit * format * [SWDEV-518081] Simplify Metric Loading (#243) * [SWDEV-518071] Return HSA not loaded status (device counter collection) This is a state that a caller would want to know about to understand if they got no counters because of a failure or if they were trying to collect counters too early (as is the case in the sample, which can attempt to collect counters before HSA is inited). * [SWDEV-518324] Add AST update support Allows the ability for ASTs to be updated (instead of an unchangable static value). Adds a shared pointer return type to protect against static destructors/modifications from invalidating potentially in use AST definitions. No functionality/use changes in this PR. * [SWDEV-518593] Add updatable dimension cache + fix string issues (#252) * [SWDEV-518593] Add updatable dimension cache + fix string issues Updates dimension cache to use the same design pattern as AST/Metrics. Fixes the string scoping issue seen in ASTs, which appears here as well. * Add rocprofiler_create_counter Creates derived counters based on input from the API. This PR does three things: 1. Adds the API + test case 2. Validates that an AST can be constructed from the counter supplied. 3. Updates metrics, ast, and dimension caches to include the new metric. Metric should be available for use immediately after the call completes. Due to the regeneration of ASTs, this call should not be performed in performance sensitive code. * Suggestion fixes --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> * Minor tweak --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com> --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com> * Fixes for comments --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: Kandula, Venkateshwar reddy <Venkateshwarreddy.Kandula@amd.com> Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com> --------- Co-authored-by: Benjamin Welton <bewelton@amd.com> Co-authored-by: Kandula, Venkateshwar reddy <Venkateshwarreddy.Kandula@amd.com> Co-authored-by: Venkateshwar Reddy Kandula <vkandula@amd.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c30bb7cbda
Коммит
007285272b
@@ -76,17 +76,18 @@ auto
|
||||
findDeviceMetrics(const hsa::AgentCache& agent, const std::unordered_set<std::string>& metrics)
|
||||
{
|
||||
std::vector<counters::Metric> ret;
|
||||
auto all_counters = counters::getMetricMap();
|
||||
auto mets = counters::loadMetrics();
|
||||
const auto& all_counters = mets->arch_to_metric;
|
||||
|
||||
ROCP_INFO << "Looking up counters for " << std::string(agent.name());
|
||||
auto gfx_metrics = common::get_val(*all_counters, std::string(agent.name()));
|
||||
const auto* gfx_metrics = common::get_val(all_counters, std::string(agent.name()));
|
||||
if(!gfx_metrics)
|
||||
{
|
||||
ROCP_ERROR << "No counters found for " << std::string(agent.name());
|
||||
return ret;
|
||||
}
|
||||
|
||||
for(auto& counter : *gfx_metrics)
|
||||
for(const auto& counter : *gfx_metrics)
|
||||
{
|
||||
if(metrics.count(counter.name()) > 0 || metrics.empty())
|
||||
{
|
||||
@@ -246,12 +247,13 @@ TEST(core, check_packet_generation)
|
||||
* Check that required hardware counters match
|
||||
*/
|
||||
ASSERT_TRUE(profile->agent);
|
||||
auto name_str = std::string(profile->agent->name);
|
||||
auto req_counters =
|
||||
counters::get_required_hardware_counters(counters::get_ast_map(), name_str, metric);
|
||||
auto name_str = std::string(profile->agent->name);
|
||||
const auto asts = counters::get_ast_map();
|
||||
auto req_counters = counters::get_required_hardware_counters(
|
||||
asts->arch_to_counter_asts, name_str, metric);
|
||||
for(const auto& req_metric : *req_counters)
|
||||
{
|
||||
if(req_metric.special().empty())
|
||||
if(req_metric.constant().empty())
|
||||
{
|
||||
EXPECT_GT(profile->reqired_hw_counters.count(req_metric), 0)
|
||||
<< "Could not find metric - " << req_metric.name();
|
||||
@@ -811,3 +813,47 @@ TEST_YAML_LOAD:
|
||||
2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(core, create_counter)
|
||||
{
|
||||
std::vector<Metric> to_add = {
|
||||
Metric("", "SQ_WAVES_REDUCE_T", "", "", "", "reduce(SQ_WAVES,sum)", "", 10000),
|
||||
Metric("", "SQ_WAVES_AVR_T", "", "", "", "reduce(SQ_WAVES,avr)", "", 10001),
|
||||
Metric("", "SQ_WAVES_INVALID", "", "", "", "reduce(ABC,avr)", "", 10002),
|
||||
};
|
||||
|
||||
ASSERT_EQ(hsa_init(), HSA_STATUS_SUCCESS);
|
||||
test_init();
|
||||
|
||||
registration::init_logging();
|
||||
registration::set_init_status(-1);
|
||||
context::push_client(1);
|
||||
auto agents = hsa::get_queue_controller()->get_supported_agents();
|
||||
for(const auto& [_, agent] : agents)
|
||||
{
|
||||
for(auto& metric : to_add)
|
||||
{
|
||||
rocprofiler_counter_id_t id;
|
||||
auto status = rocprofiler_create_counter(metric.name().c_str(),
|
||||
metric.name().size(),
|
||||
metric.expression().c_str(),
|
||||
metric.expression().size(),
|
||||
metric.description().c_str(),
|
||||
metric.description().size(),
|
||||
agent.get_rocp_agent()->id,
|
||||
&id);
|
||||
auto metrics = findDeviceMetrics(agent, {metric.name()});
|
||||
if(metric.name() == "SQ_WAVES_INVALID")
|
||||
{
|
||||
EXPECT_EQ(status, ROCPROFILER_STATUS_ERROR_AST_GENERATION_FAILED);
|
||||
EXPECT_TRUE(metrics.empty());
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_EQ(metrics.size(), 1);
|
||||
EXPECT_EQ(metric.name(), metrics[0].name());
|
||||
EXPECT_EQ(metric.expression(), metrics[0].expression());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user