Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to append arch-specific stats to report definitions #508

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sparta/example/CoreModel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ sparta_named_test_no_valgrind(sparta_core_example_simdb_configure_opts6_wildcard
sparta_named_test_no_valgrind(sparta_core_example_simdb_perf_async_task_controller sparta_core_example -i 50k --feature simdb-perf-async-ctrl 1)
sparta_named_test(sparta_core_example_collect_legacy_reports sparta_core_example -i 10k --report all_json_formats.yaml --collect-legacy-reports collection/dir)
sparta_named_test(sparta_core_example_collect_legacy_reports_specific_format sparta_core_example -i 10k --report all_json_formats.yaml --collect-legacy-reports collection/dir json json_reduced)
sparta_named_test(sparta_core_example_arch_report_simple sparta_core_example -i 10k --arch simple --arch-search-dir . --report top arch_report.yaml 1)
sparta_named_test(sparta_core_example_arch_report_default sparta_core_example -i 10k --report top arch_report.yaml 1)

# get_target_property(OUT sparta_core_example LINK_LIBRARIES)
# message(STATUS "THIS OUT: ${OUT}")
9 changes: 9 additions & 0 deletions sparta/example/CoreModel/arch_report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: "Summary Performance Report"
style:
decimal_places: 2
content:
cycles : Total cycles consumed
simple-arch-content:
cpu.core*.rob.stats.total_number_retired : Total Instructions Retired
other-arch-content:
cpu.core*.rob.stats.ipc : IPC
13 changes: 13 additions & 0 deletions sparta/example/CoreModel/simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
top.cpu:
core0:
alu0:
extension.difficulty:
color_: "black"
shape_: "diamond"
alu1:
extension.difficulty:
color_: "green"
shape_: "circle"
params:
foo: 555
top.cpu.core*.alu*.params.ignore_inst_execute_time: true
71 changes: 71 additions & 0 deletions sparta/src/Report.cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if there's value in adding arch-content as a constexpr string (keyword) like content: KEY_ARCH_CONTENT. Of course, you still need to perform the find operation as expected

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ class ReportFileParserYAML
*/
std::stack<bool> in_content_stack_;

/*!
* \brief Are we accepting the stats inside the current content block?
* An example of when we do not accept stats is when we are parsing
* a content block for an arch that does not match the --arch at the
* command line.
*/
bool skip_content_leaves_ = false;

// Did we find an 'ignore' block?
bool in_ignore_ = false;

Expand Down Expand Up @@ -302,6 +310,12 @@ class ReportFileParserYAML
<< "\" and key \"" << assoc_key << "\" in report " << *r << std::endl;

if(in_content){
if(skip_content_leaves_){
verbose() << indent_() << "Skipping content due to arch mismatch ("
<< assoc_key << " : " << value << ")" << std::endl;
return;
}

std::string full_name = value;
if(getSubstituteForStatName(full_name, n, captures)){
r->add(n, full_name);
Expand Down Expand Up @@ -577,6 +591,10 @@ class ReportFileParserYAML
}

bool isReservedKey_(const std::string& key) const override {
if (key.find("-arch-content") != std::string::npos) {
return true;
}

return (key == KEY_REPORT
|| key == KEY_SUBREPORT
|| key == KEY_CONTENT
Expand All @@ -600,6 +618,7 @@ class ReportFileParserYAML

bool handleEnterMap_(const std::string& key,
NavVector& context) override {

bool in_content = in_content_stack_.top();
//Report* const r = report_stack_.top();
sparta_assert(report_stack_.size() > 0);
Expand Down Expand Up @@ -731,6 +750,52 @@ class ReportFileParserYAML
in_content_stack_.push(false);
return false;
}else{
const auto idx = key.find("-arch-content");
if (idx != std::string::npos) {
app::Simulation *sim = nullptr;
if (base_report_) {
if (auto ctx = base_report_->getContext()) {
sim = ctx->getSimulation();
}
}

if (!sim) {
throw SpartaException("Could not get the app::Simulation to parse key: ") << key;
}

if (auto sim_config = sim->getSimulationConfiguration()) {
skip_content_leaves_ = true;
bool dash_arch_given = false;
for (const auto &kvp : sim_config->getRunMetadata()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be handy to have sim config to enable a search of a key.

if (kvp.first == "arch") {
dash_arch_given = true;
if (kvp.second + "-arch-content" == key) {
skip_content_leaves_ = false;
break;
}
}
}

if (!dash_arch_given) {
skip_content_leaves_ = false;
verbose() << indent_() << "WARNING: You should consider using --arch at "
<< "the command line together with the *-arch-content blocks "
<< "in your report definition YAML file. This content block "
<< "will be treated as normal (not filtered for --arch)."
<< std::endl;
}

if (skip_content_leaves_) {
verbose() << indent_() << "Skipping '" << key << "' block since it does "
<< "not match the --arch given at the command line.";
}

in_content_stack_.push(true);
return false;
} else {
throw SpartaException("Could not get the app::SimulationConfiguration to parse key: ") << key;
}
}

//std::stringstream ss;
//ss << "Unexpected map start (key = \"" << key << "\") outside of a \"content\" section";
Expand Down Expand Up @@ -878,6 +943,12 @@ class ReportFileParserYAML
}
}
trigger_defn_.reset();
}else{
const auto idx = key.find("-arch-content");
if (idx != std::string::npos) {
skip_content_leaves_ = false;
return false;
}
}
}

Expand Down
Loading