LibDRAMPower.h revision 13484:3f28e9f7949b
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 35 * Omar Naji 36 * Subash Kannoth 37 * Éder F. Zulian 38 * Felipe S. Prado 39 * 40 */ 41 42#ifndef LIB_DRAM_POWER_H 43#define LIB_DRAM_POWER_H 44 45#include <stdint.h> 46#include <vector> 47 48#include "CommandAnalysis.h" 49#include "MemoryPowerModel.h" 50#include "MemCommand.h" 51#include "MemBankWiseParams.h" 52 53 54class libDRAMPower { 55 public: 56 libDRAMPower(const Data::MemorySpecification& memSpec, bool includeIoAndTermination); 57 libDRAMPower(const Data::MemorySpecification& memSpec, bool includeIoAndTermination,const Data::MemBankWiseParams& bwPowerParams); 58 ~libDRAMPower(); 59 60 void doCommand(Data::MemCommand::cmds type, 61 int bank, 62 int64_t timestamp); 63 64 void calcEnergy(); 65 66 void calcWindowEnergy(int64_t timestamp); 67 68 const Data::MemoryPowerModel::Energy& getEnergy() const; 69 const Data::MemoryPowerModel::Power& getPower() const; 70 71 // list of all commands 72 std::vector<Data::MemCommand> cmdList; 73 private: 74 void updateCounters(bool lastUpdate, int64_t timestamp = 0); 75 76 void clearCounters(int64_t timestamp); 77 78 void clearState(); 79 80 Data::MemorySpecification memSpec; 81 public: 82 Data::CommandAnalysis counters; 83 private: 84 bool includeIoAndTermination; 85 Data:: MemBankWiseParams bwPowerParams; 86 // Object of MemoryPowerModel which contains the results 87 // Energies(pJ) stored in energy, Powers(mW) stored in power. Number of 88 // each command stored in timings. 89 Data::MemoryPowerModel mpm; 90}; 91 92#endif // ifndef LIB_DRAM_POWER_H 93