1/* 2 * Copyright (c) 2012-2014, TU Delft 3 * Copyright (c) 2012-2014, TU Eindhoven 4 * Copyright (c) 2012-2014, TU Kaiserslautern 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * 3. Neither the name of the copyright holder nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 23 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 *
| 1/* 2 * Copyright (c) 2012-2014, TU Delft 3 * Copyright (c) 2012-2014, TU Eindhoven 4 * Copyright (c) 2012-2014, TU Kaiserslautern 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are 9 * met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * 3. Neither the name of the copyright holder nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 23 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 28 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 *
|
34 * Authors: Matthias Jung, Omar Naji
| 34 * Authors: Matthias Jung 35 * Omar Naji 36 * Subash Kannoth 37 * Éder F. Zulian 38 * Felipe S. Prado
|
35 * 36 */ 37 38#include "LibDRAMPower.h" 39 40using namespace Data; 41 42libDRAMPower::libDRAMPower(const MemorySpecification& memSpec, bool includeIoAndTermination) : 43 memSpec(memSpec),
| 39 * 40 */ 41 42#include "LibDRAMPower.h" 43 44using namespace Data; 45 46libDRAMPower::libDRAMPower(const MemorySpecification& memSpec, bool includeIoAndTermination) : 47 memSpec(memSpec),
|
44 counters(CommandAnalysis(memSpec.memArchSpec.nbrOfBanks)), 45 includeIoAndTermination(includeIoAndTermination)
| 48 counters(memSpec), 49 includeIoAndTermination(includeIoAndTermination), 50 mpm(MemoryPowerModel())
|
46{
| 51{
|
| 52 MemBankWiseParams p (100,100,false,0,false,static_cast<unsigned>(memSpec.memArchSpec.nbrOfBanks)); 53 libDRAMPower DRAMPower = libDRAMPower(memSpec, 0, p);
|
47} 48
| 54} 55
|
| 56libDRAMPower::libDRAMPower(const MemorySpecification& memSpec, bool includeIoAndTermination, const Data::MemBankWiseParams& bwPowerParams) : 57 memSpec(memSpec), 58 counters(CommandAnalysis(memSpec)), 59 includeIoAndTermination(includeIoAndTermination), 60 bwPowerParams(bwPowerParams) 61{ 62} 63
|
49libDRAMPower::~libDRAMPower() 50{ 51} 52 53void libDRAMPower::doCommand(MemCommand::cmds type, int bank, int64_t timestamp) 54{ 55 MemCommand cmd(type, static_cast<unsigned>(bank), timestamp); 56 cmdList.push_back(cmd); 57} 58
| 64libDRAMPower::~libDRAMPower() 65{ 66} 67 68void libDRAMPower::doCommand(MemCommand::cmds type, int bank, int64_t timestamp) 69{ 70 MemCommand cmd(type, static_cast<unsigned>(bank), timestamp); 71 cmdList.push_back(cmd); 72} 73
|
59void libDRAMPower::updateCounters(bool lastUpdate)
| 74void libDRAMPower::updateCounters(bool lastUpdate, int64_t timestamp)
|
60{
| 75{
|
61 counters.getCommands(memSpec, cmdList, lastUpdate);
| 76 counters.getCommands(cmdList, lastUpdate, timestamp);
|
62 cmdList.clear(); 63} 64 65void libDRAMPower::calcEnergy() 66{
| 77 cmdList.clear(); 78} 79 80void libDRAMPower::calcEnergy() 81{
|
67 mpm.power_calc(memSpec, counters, includeIoAndTermination);
| 82 updateCounters(true); 83 mpm.power_calc(memSpec, counters, includeIoAndTermination, bwPowerParams);
|
68} 69
| 84} 85
|
| 86void libDRAMPower::calcWindowEnergy(int64_t timestamp) 87{ 88 doCommand(MemCommand::NOP, 0, timestamp); 89 updateCounters(false, timestamp); 90 mpm.power_calc(memSpec, counters, includeIoAndTermination, bwPowerParams); 91 clearCounters(timestamp); 92} 93 94
|
70void libDRAMPower::clearState() 71{ 72 counters.clear(); 73} 74 75void libDRAMPower::clearCounters(int64_t timestamp) 76{ 77 counters.clearStats(timestamp); 78} 79 80const Data::MemoryPowerModel::Energy& libDRAMPower::getEnergy() const 81{ 82 return mpm.energy; 83} 84 85const Data::MemoryPowerModel::Power& libDRAMPower::getPower() const 86{ 87 return mpm.power; 88}
| 95void libDRAMPower::clearState() 96{ 97 counters.clear(); 98} 99 100void libDRAMPower::clearCounters(int64_t timestamp) 101{ 102 counters.clearStats(timestamp); 103} 104 105const Data::MemoryPowerModel::Energy& libDRAMPower::getEnergy() const 106{ 107 return mpm.energy; 108} 109 110const Data::MemoryPowerModel::Power& libDRAMPower::getPower() const 111{ 112 return mpm.power; 113}
|