From f30ed2991f28d771f4193588dc46ec4583e8ada1 Mon Sep 17 00:00:00 2001 From: Emily Brickey Date: Tue, 25 Aug 2020 16:05:41 -0700 Subject: [PATCH] cpu-o3: convert elastic trace to new style stats Change-Id: If767f17b905a77e12058022a9e8bc65b854978a4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/33399 Reviewed-by: Andreas Sandberg Maintainer: Andreas Sandberg Tested-by: kokoro --- src/cpu/o3/probe/elastic_trace.cc | 103 +++++++++++------------------- src/cpu/o3/probe/elastic_trace.hh | 79 ++++++++++++----------- 2 files changed, 76 insertions(+), 106 deletions(-) diff --git a/src/cpu/o3/probe/elastic_trace.cc b/src/cpu/o3/probe/elastic_trace.cc index 8292c336e..b40d28197 100644 --- a/src/cpu/o3/probe/elastic_trace.cc +++ b/src/cpu/o3/probe/elastic_trace.cc @@ -54,7 +54,8 @@ ElasticTrace::ElasticTrace(const ElasticTraceParams* params) instTraceStream(nullptr), startTraceInst(params->startTraceInst), allProbesReg(false), - traceVirtAddr(params->traceVirtAddr) + traceVirtAddr(params->traceVirtAddr), + stats(this) { cpu = dynamic_cast*>(params->manager); fatal_if(!cpu, "Manager of %s is not of type O3CPU and thus does not "\ @@ -193,8 +194,8 @@ ElasticTrace::recordExecTick(const DynInstConstPtr& dyn_inst) } exec_info_ptr->executeTick = curTick(); - maxTempStoreSize = std::max(tempStore.size(), - (std::size_t)maxTempStoreSize.value()); + stats.maxTempStoreSize = std::max(tempStore.size(), + (std::size_t)stats.maxTempStoreSize.value()); } void @@ -282,8 +283,8 @@ ElasticTrace::updateRegDep(const DynInstConstPtr& dyn_inst) physRegDepMap[phys_dest_reg->flatIndex()] = seq_num; } } - maxPhysRegDepMapSize = std::max(physRegDepMap.size(), - (std::size_t)maxPhysRegDepMapSize.value()); + stats.maxPhysRegDepMapSize = std::max(physRegDepMap.size(), + (std::size_t)stats.maxPhysRegDepMapSize.value()); } void @@ -450,7 +451,7 @@ ElasticTrace::addDepTraceRecord(const DynInstConstPtr& head_inst, TraceInfo* reg_dep = trace_info_itr->second; reg_dep->numDepts++; compDelayPhysRegDep(reg_dep, new_record); - ++numRegDep; + ++stats.numRegDep; } else { // The instruction that this has a register dependency on was // not added to the trace because of one of the following @@ -533,7 +534,7 @@ ElasticTrace::updateCommitOrderDep(TraceInfo* new_record, if (hasLoadCompleted(past_record, execute_tick)) { // Assign rob dependency and calculate the computational delay assignRobDep(past_record, new_record); - ++numOrderDepStores; + ++stats.numRegDep; return; } } else { @@ -542,7 +543,7 @@ ElasticTrace::updateCommitOrderDep(TraceInfo* new_record, if (hasStoreCommitted(past_record, execute_tick)) { // Assign rob dependency and calculate the computational delay assignRobDep(past_record, new_record); - ++numOrderDepStores; + ++stats.numRegDep; return; } } @@ -567,15 +568,15 @@ ElasticTrace::updateIssueOrderDep(TraceInfo* new_record) if (new_record->isLoad()) { // The execution time of a load is when a request is sent execute_tick = new_record->executeTick; - ++numIssueOrderDepLoads; + ++stats.numIssueOrderDepLoads; } else if (new_record->isStore()) { // The execution time of a store is when it is sent, i.e. committed execute_tick = curTick(); - ++numIssueOrderDepStores; + ++stats.numIssueOrderDepStores; } else { // The execution time of a non load/store is when it completes execute_tick = new_record->toCommitTick; - ++numIssueOrderDepOther; + ++stats.numIssueOrderDepOther; } // We search if this record has an issue order dependency on a past record. @@ -610,8 +611,8 @@ ElasticTrace::assignRobDep(TraceInfo* past_record, TraceInfo* new_record) { // Increment number of dependents of the past record ++(past_record->numDepts); // Update stat to log max number of dependents - maxNumDependents = std::max(past_record->numDepts, - (uint32_t)maxNumDependents.value()); + stats.maxNumDependents = std::max(past_record->numDepts, + (uint32_t)stats.maxNumDependents.value()); } bool @@ -863,7 +864,7 @@ ElasticTrace::writeDepTrace(uint32_t num_to_write) } else { // Don't write the node to the trace but note that we have filtered // out a node. - ++numFilteredNodes; + ++stats.numFilteredNodes; ++num_filtered_nodes; } dep_trace_itr++; @@ -874,59 +875,27 @@ ElasticTrace::writeDepTrace(uint32_t num_to_write) depTrace.erase(dep_trace_itr_start, dep_trace_itr); } -void -ElasticTrace::regStats() { - ProbeListenerObject::regStats(); - - using namespace Stats; - numRegDep - .name(name() + ".numRegDep") - .desc("Number of register dependencies recorded during tracing") - ; - - numOrderDepStores - .name(name() + ".numOrderDepStores") - .desc("Number of commit order (rob) dependencies for a store recorded" - " on a past load/store during tracing") - ; - - numIssueOrderDepLoads - .name(name() + ".numIssueOrderDepLoads") - .desc("Number of loads that got assigned issue order dependency" - " because they were dependency-free") - ; - - numIssueOrderDepStores - .name(name() + ".numIssueOrderDepStores") - .desc("Number of stores that got assigned issue order dependency" - " because they were dependency-free") - ; - - numIssueOrderDepOther - .name(name() + ".numIssueOrderDepOther") - .desc("Number of non load/store insts that got assigned issue order" - " dependency because they were dependency-free") - ; - - numFilteredNodes - .name(name() + ".numFilteredNodes") - .desc("No. of nodes filtered out before writing the output trace") - ; - - maxNumDependents - .name(name() + ".maxNumDependents") - .desc("Maximum number or dependents on any instruction") - ; - - maxTempStoreSize - .name(name() + ".maxTempStoreSize") - .desc("Maximum size of the temporary store during the run") - ; - - maxPhysRegDepMapSize - .name(name() + ".maxPhysRegDepMapSize") - .desc("Maximum size of register dependency map") - ; +ElasticTrace::ElasticTraceStats::ElasticTraceStats(Stats::Group *parent) + : Stats::Group(parent), + ADD_STAT(numRegDep, "Number of register dependencies recorded during" + " tracing"), + ADD_STAT(numOrderDepStores, "Number of commit order (rob) dependencies" + " for a store recorded on a past load/store during tracing"), + ADD_STAT(numIssueOrderDepLoads, "Number of loads that got assigned" + " issue order dependency because they were dependency-free"), + ADD_STAT(numIssueOrderDepStores, "Number of stores that got assigned" + " issue order dependency because they were dependency-free"), + ADD_STAT(numIssueOrderDepOther, "Number of non load/store insts that" + " got assigned issue order dependency because they were" + " dependency-free"), + ADD_STAT(numFilteredNodes, "No. of nodes filtered out before writing" + " the output trace"), + ADD_STAT(maxNumDependents, "Maximum number or dependents on any" + " instruction"), + ADD_STAT(maxTempStoreSize, "Maximum size of the temporary store during" + " the run"), + ADD_STAT(maxPhysRegDepMapSize, "Maximum size of register dependency map") +{ } const std::string& diff --git a/src/cpu/o3/probe/elastic_trace.hh b/src/cpu/o3/probe/elastic_trace.hh index 175f5464e..ddd94083f 100644 --- a/src/cpu/o3/probe/elastic_trace.hh +++ b/src/cpu/o3/probe/elastic_trace.hh @@ -175,9 +175,6 @@ class ElasticTrace : public ProbeListenerObject */ void addCommittedInst(const DynInstConstPtr& head_inst); - /** Register statistics for the elastic trace. */ - void regStats(); - /** Event to trigger registering this listener for all probe points. */ EventFunctionWrapper regEtraceListenersEvent; @@ -507,50 +504,54 @@ class ElasticTrace : public ProbeListenerObject */ bool hasCompCompleted(TraceInfo* past_record, Tick execute_tick) const; - /** Number of register dependencies recorded during tracing */ - Stats::Scalar numRegDep; + struct ElasticTraceStats : public Stats::Group { + ElasticTraceStats(Stats::Group *parent); - /** - * Number of stores that got assigned a commit order dependency - * on a past load/store. - */ - Stats::Scalar numOrderDepStores; + /** Number of register dependencies recorded during tracing */ + Stats::Scalar numRegDep; - /** - * Number of load insts that got assigned an issue order dependency - * because they were dependency-free. - */ - Stats::Scalar numIssueOrderDepLoads; + /** + * Number of stores that got assigned a commit order dependency + * on a past load/store. + */ + Stats::Scalar numOrderDepStores; - /** - * Number of store insts that got assigned an issue order dependency - * because they were dependency-free. - */ - Stats::Scalar numIssueOrderDepStores; + /** + * Number of load insts that got assigned an issue order dependency + * because they were dependency-free. + */ + Stats::Scalar numIssueOrderDepLoads; - /** - * Number of non load/store insts that got assigned an issue order - * dependency because they were dependency-free. - */ - Stats::Scalar numIssueOrderDepOther; + /** + * Number of store insts that got assigned an issue order dependency + * because they were dependency-free. + */ + Stats::Scalar numIssueOrderDepStores; - /** Number of filtered nodes */ - Stats::Scalar numFilteredNodes; + /** + * Number of non load/store insts that got assigned an issue order + * dependency because they were dependency-free. + */ + Stats::Scalar numIssueOrderDepOther; - /** Maximum number of dependents on any instruction */ - Stats::Scalar maxNumDependents; + /** Number of filtered nodes */ + Stats::Scalar numFilteredNodes; - /** - * Maximum size of the temporary store mostly useful as a check that it is - * not growing - */ - Stats::Scalar maxTempStoreSize; + /** Maximum number of dependents on any instruction */ + Stats::Scalar maxNumDependents; - /** - * Maximum size of the map that holds the last writer to a physical - * register. - * */ - Stats::Scalar maxPhysRegDepMapSize; + /** + * Maximum size of the temporary store mostly useful as a check that + * it is not growing + */ + Stats::Scalar maxTempStoreSize; + + /** + * Maximum size of the map that holds the last writer to a physical + * register. + */ + Stats::Scalar maxPhysRegDepMapSize; + } stats; }; #endif//__CPU_O3_PROBE_ELASTIC_TRACE_HH__ -- 2.30.2