Skip to content

Commit

Permalink
Provide a way to append arch-specific stats to report definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
colby-nyce authored and klingaard committed Aug 2, 2024
1 parent 3092846 commit 33672d4
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
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
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()) {
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

0 comments on commit 33672d4

Please sign in to comment.