metrics and counter importing
This commit is contained in:
@@ -207,6 +207,10 @@ class Context {
|
||||
const Metric* metric = metrics_->Get(name);
|
||||
if (metric == NULL)
|
||||
EXC_RAISING(HSA_STATUS_ERROR, "input metric '" << name << "' is not found");
|
||||
#if 0
|
||||
std::cout << " " << name << (metric->GetExpr() ? " = " + metric->GetExpr()->String() : " counter") << std::endl;
|
||||
#endif
|
||||
|
||||
auto ret = metrics_map_.insert({name, metric});
|
||||
if (!ret.second)
|
||||
EXC_RAISING(HSA_STATUS_ERROR, "input metric '" << name
|
||||
|
||||
+13
-7
@@ -146,15 +146,21 @@ class MetricsDict {
|
||||
const_iterator_t Begin() const { return cache_.begin(); }
|
||||
const_iterator_t End() const { return cache_.end(); }
|
||||
|
||||
xml::Xml::nodes_t GetNodes(const std::string& scope) const {
|
||||
return xml_->GetNodes("top." + scope + ".metric");
|
||||
}
|
||||
|
||||
private:
|
||||
MetricsDict(const util::AgentInfo* agent_info) : xml_(NULL), agent_info_(agent_info) {
|
||||
const char* xml_name = getenv("ROCP_METRICS");
|
||||
if (xml_name != NULL) {
|
||||
//std::cout << "ROCProfiler: importing '" << xml_name << "':" << std::endl;
|
||||
xml_ = xml::Xml::Create(xml_name);
|
||||
if (xml_ == NULL) EXC_RAISING(HSA_STATUS_ERROR, "metrics .xml open error '" << xml_name << "'");
|
||||
xml_->AddConst("top.const.metric", "NUM_SIMDS", 64);
|
||||
xml_->AddConst("top.const.metric", "NUM_SHADER_ENGINES", 4);
|
||||
std::cout << "ROCProfiler: importing '" << xml_name << "':" << std::endl;
|
||||
xml_->AddConst("top.const.metric", "MAX_WAVE_SIZE", agent_info->max_wave_size);
|
||||
xml_->AddConst("top.const.metric", "CU_NUM", agent_info->cu_num);
|
||||
xml_->AddConst("top.const.metric", "SIMD_NUM", agent_info->simds_per_cu * agent_info->cu_num);
|
||||
xml_->AddConst("top.const.metric", "SE_NUM", agent_info->se_num);
|
||||
ImportMetrics(agent_info, "const");
|
||||
ImportMetrics(agent_info, agent_info->gfxip);
|
||||
ImportMetrics(agent_info, "global");
|
||||
@@ -178,11 +184,11 @@ class MetricsDict {
|
||||
}
|
||||
|
||||
void ImportMetrics(const util::AgentInfo* agent_info, const std::string& scope) {
|
||||
auto scope_list = xml_->GetNodes("top." + scope + ".metric");
|
||||
if (!scope_list.empty()) {
|
||||
std::cout << " " << scope_list.size() << " " << scope << " metrics found" << std::endl;
|
||||
auto metrics_list = xml_->GetNodes("top." + scope + ".metric");
|
||||
if (!metrics_list.empty()) {
|
||||
//std::cout << " " << metrics_list.size() << " " << scope << " metrics found" << std::endl;
|
||||
|
||||
for (auto node : scope_list) {
|
||||
for (auto node : metrics_list) {
|
||||
const std::string name = node->opts["name"];
|
||||
const std::string expr_str = node->opts["expr"];
|
||||
std::string descr = node->opts["descr"];
|
||||
|
||||
+11
-11
@@ -367,25 +367,25 @@ PUBLIC_API hsa_status_t rocprofiler_iterate_info(
|
||||
}
|
||||
|
||||
while (hsa_rsrc->GetGpuAgentInfo(agent_idx, &agent_info)) {
|
||||
info.agent_idx = agent_idx;
|
||||
info.agent_index = agent_idx;
|
||||
|
||||
switch (kind) {
|
||||
case ROCPROFILER_INFO_KIND_METRIC:
|
||||
{
|
||||
const rocprofiler::MetricsDict* dict = rocprofiler::GetMetrics(agent_info->dev_id);
|
||||
rocprofiler::MetricsDict::const_iterator_t it = dict->Begin();
|
||||
rocprofiler::MetricsDict::const_iterator_t end = dict->End();
|
||||
while (it != end) {
|
||||
const rocprofiler::Metric* metric = it->second;
|
||||
std::string name = metric->GetName();
|
||||
//std::string descr = metric->GetDescr();
|
||||
const auto* expr = metric->GetExpr();
|
||||
std::string description = "Performance metric " + name + " " + ((expr == NULL) ? "basic" : "= " + expr->String());
|
||||
auto nodes_vec = dict->GetNodes(agent_info->gfxip);
|
||||
auto global_vec = dict->GetNodes("global");
|
||||
nodes_vec.insert(nodes_vec.end(), global_vec.begin(), global_vec.end());
|
||||
|
||||
for (auto* node : nodes_vec) {
|
||||
const std::string& name = node->opts["name"];
|
||||
const std::string& descr = node->opts["descr"];
|
||||
const std::string& expr = node->opts["expr"];
|
||||
info.metric.name = strdup(name.c_str());
|
||||
info.metric.description = strdup(description.c_str());
|
||||
info.metric.description = strdup(descr.c_str());
|
||||
info.metric.expr = expr.empty() ? NULL : strdup(expr.c_str());
|
||||
status = callback(info, data);
|
||||
if (status != HSA_STATUS_SUCCESS) break;
|
||||
++it;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user