diff --git a/src/cpu/base.cc b/src/cpu/base.cc index 801a95b087..7c1930744c 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -196,7 +196,13 @@ BaseCPU::BaseCPU(const Params &p, bool is_checker) executeStats.reserve(numThreads); commitStats.reserve(numThreads); for (int i = 0; i < numThreads; i++) { - fetchStats.emplace_back(new FetchCPUStats(this, i)); + // create fetchStat object for thread i and set rate formulas + FetchCPUStats* fetchStatptr = new FetchCPUStats(this, i); + fetchStatptr->fetchRate = fetchStatptr->numInsts / baseStats.numCycles; + fetchStatptr->branchRate = fetchStatptr->numBranches / + baseStats.numCycles; + fetchStats.emplace_back(fetchStatptr); + executeStats.emplace_back(new ExecuteCPUStats(this, i)); // create commitStat object for thread i and set ipc, cpi formulas CommitCPUStats* commitStatptr = new CommitCPUStats(this, i); @@ -862,15 +868,31 @@ FetchCPUStats::FetchCPUStats(statistics::Group *parent, int thread_id) "Number of instructions fetched (thread level)"), ADD_STAT(numOps, statistics::units::Count::get(), "Number of ops (including micro ops) fetched (thread level)"), + ADD_STAT(fetchRate, statistics::units::Rate< + statistics::units::Count, statistics::units::Cycle>::get(), + "Number of inst fetches per cycle"), ADD_STAT(numBranches, statistics::units::Count::get(), "Number of branches fetched"), + ADD_STAT(branchRate, statistics::units::Ratio::get(), + "Number of branch fetches per cycle"), + ADD_STAT(icacheStallCycles, statistics::units::Cycle::get(), + "ICache total stall cycles"), ADD_STAT(numFetchSuspends, statistics::units::Count::get(), "Number of times Execute suspended instruction fetching") { + fetchRate + .flags(statistics::total); + numBranches .prereq(numBranches); + branchRate + .flags(statistics::total); + + icacheStallCycles + .prereq(icacheStallCycles); + } // means it is incremented in a vector indexing and not directly @@ -981,6 +1003,9 @@ CommitCPUStats::CommitCPUStats(statistics::Group *parent, int thread_id) ADD_STAT(committedControl, statistics::units::Count::get(), "Class of control type instructions committed") { + numInsts + .prereq(numInsts); + cpi.precision(6); ipc.precision(6); diff --git a/src/cpu/base.hh b/src/cpu/base.hh index f1739679f6..946ea6ba87 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -696,9 +696,18 @@ class BaseCPU : public ClockedObject /* Total number of operations fetched */ statistics::Scalar numOps; + /* Number of instruction fetched per cycle. */ + statistics::Formula fetchRate; + /* Total number of branches fetched */ statistics::Scalar numBranches; + /* Number of branch fetches per cycle. */ + statistics::Formula branchRate; + + /* Number of cycles stalled due to an icache miss */ + statistics::Scalar icacheStallCycles; + /* Number of times fetch was asked to suspend by Execute */ statistics::Scalar numFetchSuspends; diff --git a/src/cpu/o3/commit.cc b/src/cpu/o3/commit.cc index 63bf7aebc4..82ecc0140e 100644 --- a/src/cpu/o3/commit.cc +++ b/src/cpu/o3/commit.cc @@ -1019,6 +1019,8 @@ Commit::commitInsts() if (commit_success) { ++num_committed; + cpu->commitStats[tid] + ->committedInstType[head_inst->opClass()]++; stats.committedInstType[tid][head_inst->opClass()]++; ppCommit->notify(head_inst); diff --git a/src/cpu/o3/fetch.cc b/src/cpu/o3/fetch.cc index d3cdd2c761..89d1b81197 100644 --- a/src/cpu/o3/fetch.cc +++ b/src/cpu/o3/fetch.cc @@ -540,6 +540,8 @@ Fetch::lookupAndUpdateNextPC(const DynInstPtr &inst, PCStateBase &next_pc) inst->setPredTarg(next_pc); inst->setPredTaken(predict_taken); + // update both old and new stats + cpu->fetchStats[tid]->numBranches++; ++fetchStats.branches; if (predict_taken) { @@ -1145,8 +1147,11 @@ Fetch::fetch(bool &status_change) fetchCacheLine(fetchAddr, tid, this_pc.instAddr()); - if (fetchStatus[tid] == IcacheWaitResponse) + if (fetchStatus[tid] == IcacheWaitResponse) { + // update both old and new stats ++fetchStats.icacheStallCycles; + cpu->fetchStats[tid]->icacheStallCycles++; + } else if (fetchStatus[tid] == ItlbWait) ++fetchStats.tlbCycles; else @@ -1242,7 +1247,9 @@ Fetch::fetch(bool &status_change) staticInst = dec_ptr->decode(this_pc); // Increment stat of fetched instructions. + // Update both old and new stats ++fetchStats.insts; + cpu->fetchStats[tid]->numInsts++; if (staticInst->isMacroop()) { curMacroop = staticInst; @@ -1572,6 +1579,8 @@ Fetch::profileStall(ThreadID tid) ++fetchStats.squashCycles; DPRINTF(Fetch, "[tid:%i] Fetch is squashing!\n", tid); } else if (fetchStatus[tid] == IcacheWaitResponse) { + // update both old and new stats + cpu->fetchStats[tid]->icacheStallCycles++; ++fetchStats.icacheStallCycles; DPRINTF(Fetch, "[tid:%i] Fetch is waiting cache response!\n", tid);