cpu-o3: Copy general O3 fetch stats to BaseCPU::FetchCPUStats

The stats moved are from fetch.hh and fetch.cc of O3. Stat branches is
now tracked by numBranches. Stat branchRate is now tracked by
branchRate in FetchCPUStats. Stat rate is tracked by fetchRate. Stat
insts is tracked by numInsts. Stat icacheStallCycles is tracked by
icacheStallCycles in BaseCPU::FetchCPUStats.

Change-Id: I2a0a48a175bcb4322c66490f16c906dc9597f30e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69102
Tested-by: kokoro <noreply+kokoro@google.com>
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Melissa Jost
2023-03-13 11:10:14 -07:00
committed by Bobby Bruce
parent 4b70c1cacc
commit 53a12bc8ad
4 changed files with 47 additions and 2 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);