From c25857d4a9d5c5b7518e1a3e8f36573c459fd62d Mon Sep 17 00:00:00 2001 From: Colby Nyce Date: Tue, 23 Jul 2024 11:08:19 -0500 Subject: [PATCH] Provide a way to append arch-specific stats to report definitions --- sparta/example/CoreModel/CMakeLists.txt | 2 + sparta/example/CoreModel/arch_report.yaml | 9 +++ sparta/example/CoreModel/simple.yaml | 13 +++++ sparta/src/Report.cpp | 71 +++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 sparta/example/CoreModel/arch_report.yaml create mode 100644 sparta/example/CoreModel/simple.yaml diff --git a/sparta/example/CoreModel/CMakeLists.txt b/sparta/example/CoreModel/CMakeLists.txt index 75f4f5f9a0..d501a336f8 100644 --- a/sparta/example/CoreModel/CMakeLists.txt +++ b/sparta/example/CoreModel/CMakeLists.txt @@ -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}") diff --git a/sparta/example/CoreModel/arch_report.yaml b/sparta/example/CoreModel/arch_report.yaml new file mode 100644 index 0000000000..b83974a2ab --- /dev/null +++ b/sparta/example/CoreModel/arch_report.yaml @@ -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 diff --git a/sparta/example/CoreModel/simple.yaml b/sparta/example/CoreModel/simple.yaml new file mode 100644 index 0000000000..f149932f5d --- /dev/null +++ b/sparta/example/CoreModel/simple.yaml @@ -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 diff --git a/sparta/src/Report.cpp b/sparta/src/Report.cpp index be2e7eebeb..a9bd554667 100644 --- a/sparta/src/Report.cpp +++ b/sparta/src/Report.cpp @@ -117,6 +117,14 @@ class ReportFileParserYAML */ std::stack 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; @@ -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); @@ -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 @@ -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); @@ -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"; @@ -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; + } } }