diff --git a/src/cpu/base.cc b/src/cpu/base.cc index d2c0a78d44..1d293397e5 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -191,6 +191,11 @@ BaseCPU::BaseCPU(const Params &p, bool is_checker) modelResetPort.onChange([this](const bool &new_val) { setReset(new_val); }); + // create a stat group object for each thread on this core + fetchStats.reserve(numThreads); + for (int i = 0; i < numThreads; i++) { + fetchStats.emplace_back(new FetchCPUStats(this, i)); + } } void @@ -827,4 +832,18 @@ BaseCPU::GlobalStats::GlobalStats(statistics::Group *parent) hostOpRate = simOps / hostSeconds; } +BaseCPU:: +FetchCPUStats::FetchCPUStats(statistics::Group *parent, int thread_id) + : statistics::Group(parent, csprintf("fetchStats%i", thread_id).c_str()), + ADD_STAT(numBranches, statistics::units::Count::get(), + "Number of branches fetched"), + ADD_STAT(numFetchSuspends, statistics::units::Count::get(), + "Number of times Execute suspended instruction fetching") + +{ + numBranches + .prereq(numBranches); + +} + } // namespace gem5 diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 084d9b9305..d6e5d38838 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -43,6 +43,7 @@ #define __CPU_BASE_HH__ #include +#include #include "arch/generic/interrupts.hh" #include "base/statistics.hh" @@ -676,6 +677,21 @@ class BaseCPU : public ClockedObject const Cycles pwrGatingLatency; const bool powerGatingOnIdle; EventFunctionWrapper enterPwrGatingEvent; + + public: + struct FetchCPUStats : public statistics::Group + { + FetchCPUStats(statistics::Group *parent, int thread_id); + + /* Total number of branches fetched */ + statistics::Scalar numBranches; + + /* Number of times fetch was asked to suspend by Execute */ + statistics::Scalar numFetchSuspends; + + }; + + std::vector> fetchStats; }; } // namespace gem5 diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc index 5eaaf5804e..323ae2982b 100644 --- a/src/cpu/minor/execute.cc +++ b/src/cpu/minor/execute.cc @@ -1054,7 +1054,7 @@ Execute::commitInst(MinorDynInstPtr inst, bool early_memory_issue, DPRINTF(MinorInterrupt, "Suspending thread: %d from Execute" " inst: %s\n", thread_id, *inst); - cpu.stats.numFetchSuspends++; + cpu.fetchStats[thread_id]->numFetchSuspends++; updateBranchData(thread_id, BranchData::SuspendThread, inst, resume_pc, branch); diff --git a/src/cpu/minor/stats.cc b/src/cpu/minor/stats.cc index 64d4c475e0..e9ca562c16 100644 --- a/src/cpu/minor/stats.cc +++ b/src/cpu/minor/stats.cc @@ -52,8 +52,6 @@ MinorStats::MinorStats(BaseCPU *base_cpu) ADD_STAT(numDiscardedOps, statistics::units::Count::get(), "Number of ops (including micro ops) which were discarded before " "commit"), - ADD_STAT(numFetchSuspends, statistics::units::Count::get(), - "Number of times Execute suspended instruction fetching"), ADD_STAT(quiesceCycles, statistics::units::Cycle::get(), "Total number of cycles that CPU has spent quiesced or waiting " "for an interrupt"), diff --git a/src/cpu/minor/stats.hh b/src/cpu/minor/stats.hh index 1ab81f4407..524d20f85d 100644 --- a/src/cpu/minor/stats.hh +++ b/src/cpu/minor/stats.hh @@ -68,9 +68,6 @@ struct MinorStats : public statistics::Group /** Number of ops discarded before committing */ statistics::Scalar numDiscardedOps; - /** Number of times fetch was asked to suspend by Execute */ - statistics::Scalar numFetchSuspends; - /** Number of cycles in quiescent state */ statistics::Scalar quiesceCycles; diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc index 768f63ede5..b2a11fd84b 100644 --- a/src/cpu/simple/base.cc +++ b/src/cpu/simple/base.cc @@ -396,7 +396,7 @@ BaseSimpleCPU::postExecute() } if (curStaticInst->isControl()) { - ++t_info.execContextStats.numBranches; + ++fetchStats[t_info.thread->threadId()]->numBranches; } /* Power model statistics */ diff --git a/src/cpu/simple/exec_context.hh b/src/cpu/simple/exec_context.hh index 0f20763f28..d4bb017481 100644 --- a/src/cpu/simple/exec_context.hh +++ b/src/cpu/simple/exec_context.hh @@ -152,8 +152,6 @@ class SimpleExecContext : public ExecContext "ICache total stall cycles"), ADD_STAT(dcacheStallCycles, statistics::units::Cycle::get(), "DCache total stall cycles"), - ADD_STAT(numBranches, statistics::units::Count::get(), - "Number of branches fetched"), ADD_STAT(numPredictedBranches, statistics::units::Count::get(), "Number of branches predicted as taken"), ADD_STAT(numBranchMispred, statistics::units::Count::get(), @@ -203,9 +201,6 @@ class SimpleExecContext : public ExecContext numIdleCycles = idleFraction * cpu->baseStats.numCycles; numBusyCycles = notIdleFraction * cpu->baseStats.numCycles; - numBranches - .prereq(numBranches); - numPredictedBranches .prereq(numPredictedBranches); @@ -297,8 +292,6 @@ class SimpleExecContext : public ExecContext statistics::Scalar dcacheStallCycles; /// @{ - /// Total number of branches fetched - statistics::Scalar numBranches; /// Number of branches predicted as taken statistics::Scalar numPredictedBranches; /// Number of misprediced branches