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();
std::string name() const { return _name; }
/** Initializes the unit with parameters and a thread id. */
- void init(const DerivO3CPUParams ¶ms, ThreadID tid);
-
- /** Registers statistics. */
- void regStats();
+ void init(const DerivO3CPUParams ¶ms, ThreadID tid, O3CPU *cpu);
/** Determine if we are drained. */
bool isDrained() const;
/** 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__
#define __CPU_O3_MEM_DEP_UNIT_IMPL_HH__
#include <map>
+#include <memory>
#include <vector>
#include "base/debug.hh"
template <class MemDepPred, class Impl>
MemDepUnit<MemDepPred, Impl>::MemDepUnit()
- : iqPtr(NULL)
+ : iqPtr(NULL),
+ stats(nullptr)
{
}
: _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");
}
template <class MemDepPred, class Impl>
void
MemDepUnit<MemDepPred, Impl>::init(
- const DerivO3CPUParams ¶ms, ThreadID tid)
+ const DerivO3CPUParams ¶ms, ThreadID tid, O3CPU *cpu)
{
DPRINTF(MemDepUnit, "Creating MemDepUnit %i object.\n",tid);
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>
inst_entry->memDeps = store_entries.size();
if (inst->isLoad()) {
- ++conflictingLoads;
+ ++stats.conflictingLoads;
} else {
- ++conflictingStores;
+ ++stats.conflictingStores;
}
}
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).");
}
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).");
}