From 84fa2b46d93802d48b20bcff7035f0c3a3a18e08 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Fri, 16 Oct 2020 02:35:53 -0700 Subject: [PATCH] cpu-o3,stats: Update stats style for mem_dep_unit.hh Change-Id: I9bd8e9bc331f5d57c1b6320a87b14e9b94465148 Signed-off-by: Hoa Nguyen Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/36215 Reviewed-by: Daniel Carvalho Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/cpu/o3/inst_queue_impl.hh | 2 +- src/cpu/o3/mem_dep_unit.hh | 29 ++++++++++--------- src/cpu/o3/mem_dep_unit_impl.hh | 50 ++++++++++++++++----------------- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/cpu/o3/inst_queue_impl.hh b/src/cpu/o3/inst_queue_impl.hh index 5041ab4e7..44af65486 100644 --- a/src/cpu/o3/inst_queue_impl.hh +++ b/src/cpu/o3/inst_queue_impl.hh @@ -114,7 +114,7 @@ InstructionQueue::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); } diff --git a/src/cpu/o3/mem_dep_unit.hh b/src/cpu/o3/mem_dep_unit.hh index ebeb70283..f4c0f8fbb 100644 --- a/src/cpu/o3/mem_dep_unit.hh +++ b/src/cpu/o3/mem_dep_unit.hh @@ -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 ¶ms, ThreadID tid); - - /** Registers statistics. */ - void regStats(); + void init(const DerivO3CPUParams ¶ms, 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__ diff --git a/src/cpu/o3/mem_dep_unit_impl.hh b/src/cpu/o3/mem_dep_unit_impl.hh index 7af046999..bd8faf82e 100644 --- a/src/cpu/o3/mem_dep_unit_impl.hh +++ b/src/cpu/o3/mem_dep_unit_impl.hh @@ -42,6 +42,7 @@ #define __CPU_O3_MEM_DEP_UNIT_IMPL_HH__ #include +#include #include #include "base/debug.hh" @@ -52,7 +53,8 @@ template MemDepUnit::MemDepUnit() - : iqPtr(NULL) + : iqPtr(NULL), + stats(nullptr) { } @@ -61,7 +63,8 @@ MemDepUnit::MemDepUnit(const DerivO3CPUParams ¶ms) : _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::~MemDepUnit() template void MemDepUnit::init( - const DerivO3CPUParams ¶ms, ThreadID tid) + const DerivO3CPUParams ¶ms, ThreadID tid, O3CPU *cpu) { DPRINTF(MemDepUnit, "Creating MemDepUnit %i object.\n",tid); @@ -103,27 +106,22 @@ MemDepUnit::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 -void -MemDepUnit::regStats() +MemDepUnit:: +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 @@ -289,9 +287,9 @@ MemDepUnit::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::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::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)."); } -- 2.30.2