From 4b70c1cacccf4f26b73bf3cc2a9147ae01b1b452 Mon Sep 17 00:00:00 2001 From: Melissa Jost Date: Mon, 13 Mar 2023 10:55:55 -0700 Subject: [PATCH] cpu-o3: Use base instructions committed counters in O3CPU Copied committedInsts from O3 cpu to BaseCPU as numInstsNotNOP because it tracks the instructions committed that are not NOPs or prefetches. This change also does the same for commitedOps. InstsCommitted from O3 is duplicated by CommitCPUStats::numInsts. The same thing has been done with opsCommitted. Change-Id: If24d22fee552c65fc0c63dfad90fc59b17100f34 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69101 Tested-by: kokoro Maintainer: Bobby Bruce Reviewed-by: Bobby Bruce --- src/cpu/base.cc | 4 ++++ src/cpu/base.hh | 4 ++++ src/cpu/o3/commit.cc | 9 ++++++++- src/cpu/o3/cpu.cc | 4 ++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/cpu/base.cc b/src/cpu/base.cc index d7dda13ab1..801a95b087 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -954,6 +954,10 @@ CommitCPUStats::CommitCPUStats(statistics::Group *parent, int thread_id) "Number of instructions committed (thread level)"), ADD_STAT(numOps, statistics::units::Count::get(), "Number of ops (including micro ops) committed (thread level)"), + ADD_STAT(numInstsNotNOP, statistics::units::Count::get(), + "Number of instructions committed excluding NOPs or prefetches"), + ADD_STAT(numOpsNotNOP, statistics::units::Count::get(), + "Number of Ops (including micro ops) Simulated"), ADD_STAT(cpi, statistics::units::Rate< statistics::units::Cycle, statistics::units::Count>::get(), "CPI: cycles per instruction (thread level)"), diff --git a/src/cpu/base.hh b/src/cpu/base.hh index 5e2432f01d..f1739679f6 100644 --- a/src/cpu/base.hh +++ b/src/cpu/base.hh @@ -759,6 +759,10 @@ class BaseCPU : public ClockedObject statistics::Scalar numInsts; statistics::Scalar numOps; + /* Number of instructions committed that are not NOP or prefetches */ + statistics::Scalar numInstsNotNOP; + statistics::Scalar numOpsNotNOP; + /* CPI/IPC for total cycle counts and macro insts */ statistics::Formula cpi; statistics::Formula ipc; diff --git a/src/cpu/o3/commit.cc b/src/cpu/o3/commit.cc index b3da2d9570..63bf7aebc4 100644 --- a/src/cpu/o3/commit.cc +++ b/src/cpu/o3/commit.cc @@ -1383,9 +1383,16 @@ Commit::updateComInstStats(const DynInstPtr &inst) { ThreadID tid = inst->threadNumber; - if (!inst->isMicroop() || inst->isLastMicroop()) + if (!inst->isMicroop() || inst->isLastMicroop()) { + // update both old and new stats stats.instsCommitted[tid]++; + cpu->commitStats[tid]->numInsts++; + cpu->baseStats.numInsts++; + } + // update both old and new stats stats.opsCommitted[tid]++; + cpu->commitStats[tid]->numOps++; + cpu->baseStats.numOps++; // To match the old model, don't count nops and instruction // prefetches towards the total commit count. diff --git a/src/cpu/o3/cpu.cc b/src/cpu/o3/cpu.cc index 6732c4310e..444692d47f 100644 --- a/src/cpu/o3/cpu.cc +++ b/src/cpu/o3/cpu.cc @@ -1353,16 +1353,20 @@ CPU::instDone(ThreadID tid, const DynInstPtr &inst) { // Keep an instruction count. if (!inst->isMicroop() || inst->isLastMicroop()) { + // update both old and new stats thread[tid]->numInst++; thread[tid]->threadStats.numInsts++; cpuStats.committedInsts[tid]++; + commitStats[tid]->numInstsNotNOP++; // Check for instruction-count-based events. thread[tid]->comInstEventQueue.serviceEvents(thread[tid]->numInst); } + // update both old and new stats thread[tid]->numOp++; thread[tid]->threadStats.numOps++; cpuStats.committedOps[tid]++; + commitStats[tid]->numOpsNotNOP++; probeInstCommit(inst->staticInst, inst->pcState().instAddr()); }