From cd8023a1eebba79e60a62c5cd9bd0ec111d9d88c Mon Sep 17 00:00:00 2001 From: Omar Naji Date: Tue, 29 Jul 2014 17:22:44 +0100 Subject: mem: DRAMPower integration for on-line DRAM power stats This patch takes the final step in integrating DRAMPower and adds the appropriate calls in the DRAM controller to provide the command trace and extract the power and energy stats. The debug printouts are still left in place, but will eventually be removed. At the moment the DRAM power calculation is always on when using the DRAM controller model. The run-time impact of this addition is around 1.5% when looking at the total host seconds of the regressions. We deem this a sensible trade-off to avoid the complication of adding an enable/disable mechanism. --- src/mem/dram_ctrl.hh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/mem/dram_ctrl.hh') diff --git a/src/mem/dram_ctrl.hh b/src/mem/dram_ctrl.hh index cc2bd13fd..cb2197841 100644 --- a/src/mem/dram_ctrl.hh +++ b/src/mem/dram_ctrl.hh @@ -60,6 +60,7 @@ #include "mem/qport.hh" #include "params/DRAMCtrl.hh" #include "sim/eventq.hh" +#include "mem/drampower.hh" /** * The DRAM controller is a single-channel memory controller capturing @@ -677,6 +678,20 @@ class DRAMCtrl : public AbstractMemory Stats::Formula pageHitRate; Stats::Vector pwrStateTime; + //Command energies + Stats::Vector actEnergy; + Stats::Vector preEnergy; + Stats::Vector readEnergy; + Stats::Vector writeEnergy; + Stats::Vector refreshEnergy; + //Active Background Energy + Stats::Vector actBackEnergy; + //Precharge Background Energy + Stats::Vector preBackEnergy; + Stats::Vector totalEnergy; + //Power Consumed + Stats::Vector averagePower; + // Track when we transitioned to the current power state Tick pwrStateTick; @@ -686,12 +701,42 @@ class DRAMCtrl : public AbstractMemory // Holds the value of the rank of burst issued uint8_t activeRank; + // timestamp offset + uint64_t timeStampOffset; + /** @todo this is a temporary workaround until the 4-phase code is * committed. upstream caches needs this packet until true is returned, so * hold onto it for deletion until a subsequent call */ std::vector pendingDelete; + // One DRAMPower instance per rank + std::vector rankPower; + + /** + * This function increments the energy when called. If stats are + * dumped periodically, note accumulated energy values will + * appear in the stats (even if the stats are reset). This is a + * result of the energy values coming from DRAMPower, and there + * is currently no support for resetting the state. + * + * @param rank Currrent rank + */ + void updatePowerStats(uint8_t rank); + + /** + * Function for sorting commands in the command list of DRAMPower. + * + * @param a Memory Command in command list of DRAMPower library + * @param next Memory Command in command list of DRAMPower + * @return true if timestamp of Command 1 < timestamp of Command 2 + */ + static bool sortTime(const Data::MemCommand& m1, + const Data::MemCommand& m2) { + return m1.getTime() < m2.getTime(); + }; + + public: void regStats(); -- cgit v1.2.3