cpu-o3,stats: Update stats style for mem_dep_unit.hh

Change-Id: I9bd8e9bc331f5d57c1b6320a87b14e9b94465148
Signed-off-by: Hoa Nguyen <hoanguyen@ucdavis.edu>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36215
Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Hoa Nguyen
2020-10-16 02:35:53 -07:00
parent 765ba547a2
commit 84fa2b46d9
3 changed files with 41 additions and 40 deletions

View File

@@ -114,7 +114,7 @@ InstructionQueue<Impl>::InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr,
//Initialize Mem Dependence Units
for (ThreadID tid = 0; tid < Impl::MaxThreads; tid++) {
memDepUnit[tid].init(params, tid);
memDepUnit[tid].init(params, tid, cpu_ptr);
memDepUnit[tid].setIQ(this);
}

View File

@@ -85,6 +85,7 @@ class MemDepUnit
public:
typedef typename Impl::DynInstPtr DynInstPtr;
typedef typename Impl::DynInstConstPtr DynInstConstPtr;
typedef typename Impl::O3CPU O3CPU;
/** Empty constructor. Must call init() prior to using in this case. */
MemDepUnit();
@@ -99,10 +100,7 @@ class MemDepUnit
std::string name() const { return _name; }
/** Initializes the unit with parameters and a thread id. */
void init(const DerivO3CPUParams &params, ThreadID tid);
/** Registers statistics. */
void regStats();
void init(const DerivO3CPUParams &params, ThreadID tid, O3CPU *cpu);
/** Determine if we are drained. */
bool isDrained() const;
@@ -279,15 +277,20 @@ class MemDepUnit
/** The thread id of this memory dependence unit. */
int id;
/** Stat for number of inserted loads. */
Stats::Scalar insertedLoads;
/** Stat for number of inserted stores. */
Stats::Scalar insertedStores;
/** Stat for number of conflicting loads that had to wait for a store. */
Stats::Scalar conflictingLoads;
/** Stat for number of conflicting stores that had to wait for a store. */
Stats::Scalar conflictingStores;
struct MemDepUnitStats : public Stats::Group
{
MemDepUnitStats(Stats::Group *parent);
/** Stat for number of inserted loads. */
Stats::Scalar insertedLoads;
/** Stat for number of inserted stores. */
Stats::Scalar insertedStores;
/** Stat for number of conflicting loads that had to wait for a
* store. */
Stats::Scalar conflictingLoads;
/** Stat for number of conflicting stores that had to wait for a
* store. */
Stats::Scalar conflictingStores;
} stats;
};
#endif // __CPU_O3_MEM_DEP_UNIT_HH__

View File

@@ -42,6 +42,7 @@
#define __CPU_O3_MEM_DEP_UNIT_IMPL_HH__
#include <map>
#include <memory>
#include <vector>
#include "base/debug.hh"
@@ -52,7 +53,8 @@
template <class MemDepPred, class Impl>
MemDepUnit<MemDepPred, Impl>::MemDepUnit()
: iqPtr(NULL)
: iqPtr(NULL),
stats(nullptr)
{
}
@@ -61,7 +63,8 @@ MemDepUnit<MemDepPred, Impl>::MemDepUnit(const DerivO3CPUParams &params)
: _name(params.name + ".memdepunit"),
depPred(params.store_set_clear_period, params.SSITSize,
params.LFSTSize),
iqPtr(NULL)
iqPtr(NULL),
stats(nullptr)
{
DPRINTF(MemDepUnit, "Creating MemDepUnit object.\n");
}
@@ -94,7 +97,7 @@ MemDepUnit<MemDepPred, Impl>::~MemDepUnit()
template <class MemDepPred, class Impl>
void
MemDepUnit<MemDepPred, Impl>::init(
const DerivO3CPUParams &params, ThreadID tid)
const DerivO3CPUParams &params, ThreadID tid, O3CPU *cpu)
{
DPRINTF(MemDepUnit, "Creating MemDepUnit %i object.\n",tid);
@@ -103,27 +106,22 @@ MemDepUnit<MemDepPred, Impl>::init(
depPred.init(params.store_set_clear_period, params.SSITSize,
params.LFSTSize);
std::string stats_group_name = csprintf("MemDepUnit__%i", tid);
cpu->addStatGroup(stats_group_name.c_str(), &stats);
}
template <class MemDepPred, class Impl>
void
MemDepUnit<MemDepPred, Impl>::regStats()
MemDepUnit<MemDepPred, Impl>::
MemDepUnitStats::MemDepUnitStats(Stats::Group *parent)
: Stats::Group(parent),
ADD_STAT(insertedLoads,
"Number of loads inserted to the mem dependence unit."),
ADD_STAT(insertedStores,
"Number of stores inserted to the mem dependence unit."),
ADD_STAT(conflictingLoads, "Number of conflicting loads."),
ADD_STAT(conflictingStores, "Number of conflicting stores.")
{
insertedLoads
.name(name() + ".insertedLoads")
.desc("Number of loads inserted to the mem dependence unit.");
insertedStores
.name(name() + ".insertedStores")
.desc("Number of stores inserted to the mem dependence unit.");
conflictingLoads
.name(name() + ".conflictingLoads")
.desc("Number of conflicting loads.");
conflictingStores
.name(name() + ".conflictingStores")
.desc("Number of conflicting stores.");
}
template <class MemDepPred, class Impl>
@@ -289,9 +287,9 @@ MemDepUnit<MemDepPred, Impl>::insert(const DynInstPtr &inst)
inst_entry->memDeps = store_entries.size();
if (inst->isLoad()) {
++conflictingLoads;
++stats.conflictingLoads;
} else {
++conflictingStores;
++stats.conflictingStores;
}
}
@@ -304,9 +302,9 @@ MemDepUnit<MemDepPred, Impl>::insert(const DynInstPtr &inst)
depPred.insertStore(inst->instAddr(), inst->seqNum, inst->threadNumber);
++insertedStores;
++stats.insertedStores;
} else if (inst->isLoad()) {
++insertedLoads;
++stats.insertedLoads;
} else {
panic("Unknown type! (most likely a barrier).");
}
@@ -326,9 +324,9 @@ MemDepUnit<MemDepPred, Impl>::insertNonSpec(const DynInstPtr &inst)
depPred.insertStore(inst->instAddr(), inst->seqNum, inst->threadNumber);
++insertedStores;
++stats.insertedStores;
} else if (inst->isLoad()) {
++insertedLoads;
++stats.insertedLoads;
} else {
panic("Unknown type! (most likely a barrier).");
}