Bobby Bruce has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/69100?usp=email )
Change subject: cpu: Move numInsts, numOps, ipc, cpi to BaseCPU
......................................................................
cpu: Move numInsts, numOps, ipc, cpi to BaseCPU
In BaseCPU::BaseCPUStats, numInsts and numOps track per CPU core
committed instructions and operations.
In BaseCPU::FetchCPUStats, numInsts and numOps track per thread
fetched instructions and operations.
In BaseCPU::CommitCPUStats, numInsts and numOps track per thread
committed instructions and operations.
In BaseSimpleCPU, the countInst() function has been split into
countInst(), countFetchInst(), and countCommitInst().
countFetchInst() increments numInsts and numOps
of the FetchCPUStats group for a thread. countCommitInst() increments
the numInsts and numOps of the CommitCPUStats group for a thread and
of the BaseCPUStats group for a CPU core. These functions are called
in the appropriate stage within timing.cc and atomic.cc. The call to
countInst() is left unchanged. countFetchInst() is called in
preExecute(). countCommitInst() is called in postExecute().
For MinorCPU, only the commit level numInsts and numOps stats have been
implemented.
IPC and CPI stats have been added to BaseCPUStats (core level) and
CommitCPUStats (thread level). The formulas for the IPC and CPI stats
in CommitCPUStats are set in the BaseCPU constructor, after the
CommitCPUStats stat group object has been created.
Change-Id: I71c831c44202fc7d14c75b27a33eb91204f3a273
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69100
Tested-by: kokoro <noreply+kok...@google.com>
Reviewed-by: Bobby Bruce <bbr...@ucdavis.edu>
Maintainer: Bobby Bruce <bbr...@ucdavis.edu>
---
M src/cpu/base.cc
M src/cpu/base.hh
M src/cpu/minor/execute.cc
M src/cpu/simple/base.cc
M src/cpu/simple/base.hh
5 files changed, 100 insertions(+), 1 deletion(-)
Approvals:
Bobby Bruce: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/cpu/base.cc b/src/cpu/base.cc
index 5592bf0..d7dda13 100644
--- a/src/cpu/base.cc
+++ b/src/cpu/base.cc
@@ -198,7 +198,11 @@
for (int i = 0; i < numThreads; i++) {
fetchStats.emplace_back(new FetchCPUStats(this, i));
executeStats.emplace_back(new ExecuteCPUStats(this, i));
- commitStats.emplace_back(new CommitCPUStats(this, i));
+ // create commitStat object for thread i and set ipc, cpi formulas
+ CommitCPUStats* commitStatptr = new CommitCPUStats(this, i);
+ commitStatptr->ipc = commitStatptr->numInsts / baseStats.numCycles;
+ commitStatptr->cpi = baseStats.numCycles / commitStatptr->numInsts;
+ commitStats.emplace_back(commitStatptr);
}
}
@@ -392,13 +396,28 @@
BaseCPU::
BaseCPUStats::BaseCPUStats(statistics::Group *parent)
: statistics::Group(parent),
+ ADD_STAT(numInsts, statistics::units::Count::get(),
+ "Number of instructions committed (core level)"),
+ ADD_STAT(numOps, statistics::units::Count::get(),
+ "Number of ops (including micro ops) committed (core
level)"),
ADD_STAT(numCycles, statistics::units::Cycle::get(),
"Number of cpu cycles simulated"),
+ ADD_STAT(cpi, statistics::units::Rate<
+ statistics::units::Cycle, statistics::units::Count>::get(),
+ "CPI: cycles per instruction (core level)"),
+ ADD_STAT(ipc, statistics::units::Rate<
+ statistics::units::Count, statistics::units::Cycle>::get(),
+ "IPC: instructions per cycle (core level)"),
ADD_STAT(numWorkItemsStarted, statistics::units::Count::get(),
"Number of work items this cpu started"),
ADD_STAT(numWorkItemsCompleted, statistics::units::Count::get(),
"Number of work items this cpu completed")
{
+ cpi.precision(6);
+ cpi = numCycles / numInsts;
+
+ ipc.precision(6);
+ ipc = numInsts / numCycles;
}
void
@@ -839,6 +858,10 @@
BaseCPU::
FetchCPUStats::FetchCPUStats(statistics::Group *parent, int thread_id)
: statistics::Group(parent, csprintf("fetchStats%i",
thread_id).c_str()),
+ ADD_STAT(numInsts, statistics::units::Count::get(),
+ "Number of instructions fetched (thread level)"),
+ ADD_STAT(numOps, statistics::units::Count::get(),
+ "Number of ops (including micro ops) fetched (thread level)"),
ADD_STAT(numBranches, statistics::units::Count::get(),
"Number of branches fetched"),
ADD_STAT(numFetchSuspends, statistics::units::Count::get(),
@@ -927,6 +950,16 @@
BaseCPU::
CommitCPUStats::CommitCPUStats(statistics::Group *parent, int thread_id)
: statistics::Group(parent, csprintf("commitStats%i",
thread_id).c_str()),
+ ADD_STAT(numInsts, statistics::units::Count::get(),
+ "Number of instructions committed (thread level)"),
+ ADD_STAT(numOps, statistics::units::Count::get(),
+ "Number of ops (including micro ops) committed (thread
level)"),
+ ADD_STAT(cpi, statistics::units::Rate<
+ statistics::units::Cycle, statistics::units::Count>::get(),
+ "CPI: cycles per instruction (thread level)"),
+ ADD_STAT(ipc, statistics::units::Rate<
+ statistics::units::Count, statistics::units::Cycle>::get(),
+ "IPC: instructions per cycle (thread level)"),
ADD_STAT(numMemRefs, statistics::units::Count::get(),
"Number of memory references committed"),
ADD_STAT(numFpInsts, statistics::units::Count::get(),
@@ -944,6 +977,9 @@
ADD_STAT(committedControl, statistics::units::Count::get(),
"Class of control type instructions committed")
{
+ cpi.precision(6);
+ ipc.precision(6);
+
committedInstType
.init(enums::Num_OpClass)
.flags(statistics::total | statistics::pdf | statistics::dist);
diff --git a/src/cpu/base.hh b/src/cpu/base.hh
index 934e56f..5e2432f 100644
--- a/src/cpu/base.hh
+++ b/src/cpu/base.hh
@@ -633,8 +633,14 @@
struct BaseCPUStats : public statistics::Group
{
BaseCPUStats(statistics::Group *parent);
+ // Number of CPU insts and ops committed at CPU core level
+ statistics::Scalar numInsts;
+ statistics::Scalar numOps;
// Number of CPU cycles simulated
statistics::Scalar numCycles;
+ /* CPI/IPC for total cycle counts and macro insts */
+ statistics::Formula cpi;
+ statistics::Formula ipc;
statistics::Scalar numWorkItemsStarted;
statistics::Scalar numWorkItemsCompleted;
} baseStats;
@@ -684,6 +690,12 @@
{
FetchCPUStats(statistics::Group *parent, int thread_id);
+ /* Total number of instructions fetched */
+ statistics::Scalar numInsts;
+
+ /* Total number of operations fetched */
+ statistics::Scalar numOps;
+
/* Total number of branches fetched */
statistics::Scalar numBranches;
@@ -743,6 +755,14 @@
{
CommitCPUStats(statistics::Group *parent, int thread_id);
+ /* Number of simulated instructions committed */
+ statistics::Scalar numInsts;
+ statistics::Scalar numOps;
+
+ /* CPI/IPC for total cycle counts and macro insts */
+ statistics::Formula cpi;
+ statistics::Formula ipc;
+
/* Number of committed memory references. */
statistics::Scalar numMemRefs;
diff --git a/src/cpu/minor/execute.cc b/src/cpu/minor/execute.cc
index 99d12d6..a65a77e 100644
--- a/src/cpu/minor/execute.cc
+++ b/src/cpu/minor/execute.cc
@@ -872,6 +872,9 @@
thread->numInst++;
thread->threadStats.numInsts++;
cpu.stats.numInsts++;
+ // update both old and new stas
+ cpu.commitStats[inst->id.threadId]->numInsts++;
+ cpu.baseStats.numInsts++;
/* Act on events related to instruction counts */
thread->comInstEventQueue.serviceEvents(thread->numInst);
@@ -880,6 +883,8 @@
thread->threadStats.numOps++;
cpu.stats.numOps++;
// update both old and new stats
+ cpu.commitStats[inst->id.threadId]->numOps++;
+ cpu.baseStats.numOps++;
cpu.commitStats[inst->id.threadId]
->committedInstType[inst->staticInst->opClass()]++;
cpu.stats.committedInstType[inst->id.threadId]
diff --git a/src/cpu/simple/base.cc b/src/cpu/simple/base.cc
index 40f0fa7..9e831a2 100644
--- a/src/cpu/simple/base.cc
+++ b/src/cpu/simple/base.cc
@@ -160,6 +160,34 @@
t_info.execContextStats.numOps++;
}
+void
+BaseSimpleCPU::countFetchInst()
+{
+ SimpleExecContext& t_info = *threadInfo[curThread];
+
+ if (!curStaticInst->isMicroop() || curStaticInst->isLastMicroop()) {
+ // increment thread level numInsts fetched count
+ fetchStats[t_info.thread->threadId()]->numInsts++;
+ }
+ // increment thread level numOps fetched count
+ fetchStats[t_info.thread->threadId()]->numOps++;
+}
+
+void
+BaseSimpleCPU::countCommitInst()
+{
+ SimpleExecContext& t_info = *threadInfo[curThread];
+
+ if (!curStaticInst->isMicroop() || curStaticInst->isLastMicroop()) {
+ // increment thread level and core level numInsts count
+ commitStats[t_info.thread->threadId()]->numInsts++;
+ baseStats.numInsts++;
+ }
+ // increment thread level and core level numOps count
+ commitStats[t_info.thread->threadId()]->numOps++;
+ baseStats.numOps++;
+}
+
Counter
BaseSimpleCPU::totalInsts() const
{
@@ -376,6 +404,11 @@
if (predict_taken)
++t_info.execContextStats.numPredictedBranches;
}
+
+ // increment the fetch instruction stat counters
+ if (curStaticInst) {
+ countFetchInst();
+ }
}
void
@@ -467,6 +500,9 @@
commitStats[t_info.thread->threadId()]->updateComCtrlStats(curStaticInst);
t_info.execContextStats.statExecutedInstType[curStaticInst->opClass()]++;
+ /* increment the committed numInsts and numOps stats */
+ countCommitInst();
+
if (FullSystem)
traceFunctions(instAddr);
diff --git a/src/cpu/simple/base.hh b/src/cpu/simple/base.hh
index df5290c..46a25a0 100644
--- a/src/cpu/simple/base.hh
+++ b/src/cpu/simple/base.hh
@@ -182,6 +182,8 @@
}
void countInst();
+ void countFetchInst();
+ void countCommitInst();
Counter totalInsts() const override;
Counter totalOps() const override;
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/69100?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I71c831c44202fc7d14c75b27a33eb91204f3a273
Gerrit-Change-Number: 69100
Gerrit-PatchSet: 9
Gerrit-Owner: Melissa Jost <melissakj...@gmail.com>
Gerrit-Reviewer: Bobby Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org