Merge "adding xml inheritance" into amd-master

This commit is contained in:
Evgeny Shcherbakov
2019-07-16 19:49:11 -04:00
کامیت شده توسط Gerrit Code Review
کامیت b677eebfd7
3فایلهای تغییر یافته به همراه68 افزوده شده و 16 حذف شده
+5 -1
مشاهده پرونده
@@ -184,7 +184,11 @@ class MetricsDict {
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);
if (std::string("gfx906") == agent_info->name) {
ImportMetrics(agent_info, agent_info->name);
} else {
ImportMetrics(agent_info, agent_info->gfxip);
}
ImportMetrics(agent_info, "global");
}
}
+61 -15
مشاهده پرونده
@@ -49,6 +49,7 @@ class Xml {
std::string tag;
nodes_t nodes;
opts_t opts;
const level_t* copy;
};
typedef std::vector<level_t*> nodes_vec_t;
typedef std::map<std::string, nodes_vec_t> map_t;
@@ -239,7 +240,7 @@ class Xml {
if (error) {
fprintf(stderr, "XML PreProcess failed, line '%s'\n", buf);
exit(1);
abort();
}
lseek(fd_, 0, SEEK_SET);
@@ -252,9 +253,9 @@ class Xml {
token_t token = (remainder.size()) ? remainder : NextToken();
remainder.clear();
// token_t token1 = token;
// token1.push_back('\0');
// std::cout << "> " << &token1[0] << std::endl;
// token_t token1 = token;
// token1.push_back('\0');
// std::cout << ">>> " << &token1[0] << std::endl;
// End of file
if (token.size() == 0) break;
@@ -312,14 +313,18 @@ class Xml {
if (token[j] == '=') break;
if (j == token.size()) BadFormat(token);
token[j] = '\0';
const char* key = &token[0];
const char* value = &token[j + 1];
AddOption(key, value);
const std::string key = &token[0];
const std::string value = &token[j + 1];
if (key == "base") {
Inherit(value);
} else {
AddOption(key, value);
}
}
break;
default:
std::cout << "XML parser error: wrong state: " << state_ << std::endl;
exit(1);
abort();
}
}
}
@@ -406,11 +411,11 @@ class Xml {
token.push_back('\0');
std::cout << "Error: " << file_name_ << ", line " << file_line_ << ", bad XML token '"
<< &token[0] << "'" << std::endl;
exit(1);
abort();
}
void AddLevel(const std::string& tag) {
level_t* level = new level_t;
level_t* level = new level_t{};
level->tag = tag;
if (level_) {
level_->nodes.push_back(level);
@@ -418,11 +423,7 @@ class Xml {
}
level_ = level;
std::string global_tag;
for (level_t* level : stack_) {
global_tag += level->tag + ".";
}
global_tag += tag;
std::string global_tag = GlobalTag(tag);
(*map_)[global_tag].push_back(level_);
}
@@ -431,8 +432,53 @@ class Xml {
stack_.pop_back();
}
void Copy(const level_t* from, level_t* to) {
level_t* level = to;
if (level == NULL) {
AddLevel(from->tag);
level = level_;
level->copy = from;
}
level->opts = from->opts;
for (auto node : from->nodes) {
bool found = false;
const std::string global_tag = GlobalTag(level->tag) + "." + node->tag;
for (auto item : (*map_)[global_tag]) {
if (node == item->copy) {
found = true;
break;
}
}
if (found == false) Copy(node, NULL);
}
if (to == NULL) UpLevel();
}
void Inherit(const std::string& tag) {
std::string global_tag = GlobalTag(tag);
auto it = map_->find(global_tag);
if (it == map_->end()) {
fprintf(stderr, "Node \"%s\": Base not found \"%s\"\n", level_->tag.c_str(), tag.c_str());
abort();
}
for (auto node : it->second) {
Copy(node, level_);
}
}
std::string CurrentLevel() const { return level_->tag; }
std::string GlobalTag(const std::string& tag) const {
std::string global_tag;
for (level_t* level : stack_) {
global_tag += level->tag + ".";
}
global_tag += tag;
return global_tag;
}
void AddOption(const std::string& key, const std::string& value) { level_->opts[key] = value; }
const std::string file_name_;
+2
مشاهده پرونده
@@ -36,6 +36,8 @@
<metric name="WRITE_SIZE" expr=((TCC_EA_WRREQ_sum-TCC_EA_WRREQ_64B_sum)*32+TCC_EA_WRREQ_64B_sum*64)/1024 descr="The total kilobytes written to the video memory. This is measured with all extra fetches and any cache or memory effects taken into account."></metric>
</gfx9>
<gfx906 base="gfx9"></gfx906>
<global>
# GPUBusy The percentage of time GPU was busy.
<metric