diff options
author | Radhika Jagtap <radhika.jagtap@arm.com> | 2016-12-19 10:32:40 +0000 |
---|---|---|
committer | Andreas Sandberg <andreas.sandberg@arm.com> | 2017-11-16 16:39:19 +0000 |
commit | 290a7e7c5c059c1309ca3d02ea3158e2ca9ac338 (patch) | |
tree | f04a5c7aa0f5247d467e1bb8b2139d0e11baf532 /ext/drampower/test/libdrampowertest/lib_test.cc | |
parent | 0757bef15d934b22555c396bcbcb91c0a1dffbe5 (diff) | |
download | gem5-290a7e7c5c059c1309ca3d02ea3158e2ca9ac338.tar.xz |
ext, mem: Pull DRAMPower SHA 90d6290 and rebase
This patch syncs the DRAMPower library of gem5 to the
external github (https://github.com/ravenrd/DRAMPower).
The version pulled in is the commit:
90d6290f802c29b3de9e10233ceee22290907ce6
from 30th Oct. 2016.
This change also modifies the DRAM Ctrl interaction with the
DRAMPower, due to changes in the lib API in the above version.
Previously multiple functions were called to prepare the power
lib before calling the function that would calculate the enery. With
the new API, these functions are encompassed inside the function to
calculate the energy and therefore should now be removed from the
DRAM controller.
The other key difference is the introduction of a new function called
calcWindowEnergy which can be useful for any system that wants
to do measurements over intervals. For gem5 DRAM ctrl that means we
now need to accumulate the window energy measurements into the total
stat.
Change-Id: I3570fff2805962e166ff2a1a3217ebf2d5a197fb
Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/5724
Maintainer: Nikos Nikoleris <nikos.nikoleris@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'ext/drampower/test/libdrampowertest/lib_test.cc')
-rw-r--r-- | ext/drampower/test/libdrampowertest/lib_test.cc | 169 |
1 files changed, 99 insertions, 70 deletions
diff --git a/ext/drampower/test/libdrampowertest/lib_test.cc b/ext/drampower/test/libdrampowertest/lib_test.cc index 20d4d9ebf..a79839eef 100644 --- a/ext/drampower/test/libdrampowertest/lib_test.cc +++ b/ext/drampower/test/libdrampowertest/lib_test.cc @@ -29,15 +29,16 @@ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Authors: Matthias Jung, Omar Naji + * Authors: Matthias Jung, Omar Naji, Felipe S. Prado * */ +#include <iostream> #include <string> #include "libdrampower/LibDRAMPower.h" #if USE_XERCES - #include "xmlparser/MemSpecParser.h" +#include "xmlparser/MemSpecParser.h" #endif using namespace std; @@ -45,79 +46,107 @@ using namespace Data; int main(int argc, char* argv[]) { - assert(argc == 2); - //Setup of DRAMPower for your simulation - string filename; - //type path to memspec file - filename = argv[1]; - //Parsing the Memspec specification of found in memspec folder - #if USE_XERCES - MemorySpecification memSpec(MemSpecParser::getMemSpecFromXML(filename)); - #else - MemorySpecification memSpec; - #endif - libDRAMPower test = libDRAMPower(memSpec, 0); - // During the simulation you can report activity - // to DRAMPower with the doCommand(...) function: - test.doCommand(MemCommand::ACT,0,35); - test.doCommand(MemCommand::RDA,0,50); - test.doCommand(MemCommand::ACT,4,51); - test.doCommand(MemCommand::RDA,4,66); - test.doCommand(MemCommand::ACT,0,86); - test.doCommand(MemCommand::RDA,0,101); - test.doCommand(MemCommand::ACT,2,102); - //This functionality is still not implemented. - test.updateCounters(false); - test.doCommand(MemCommand::RDA,2,117); - test.doCommand(MemCommand::ACT,5,119); - test.doCommand(MemCommand::RDA,5,134); - test.doCommand(MemCommand::ACT,0,137); - test.doCommand(MemCommand::RDA,0,152); - test.doCommand(MemCommand::ACT,3,159); - test.doCommand(MemCommand::RDA,3,174); - test.doCommand(MemCommand::ACT,0,195); - test.doCommand(MemCommand::RDA,0,210); - test.doCommand(MemCommand::ACT,4,232); - test.doCommand(MemCommand::WRA,4,247); - // Need at least tWRAPDEN = AL + CWL + BL/2 + WR + 1 cycles between WR and PDN_F_PRE - test.doCommand(MemCommand::PDN_F_PRE,3,265); + assert(argc == 2); + //Setup of DRAMPower for your simulation + string filename; + //type path to memspec file + filename = argv[1]; + //Parsing the Memspec specification of found in memspec folder +#if USE_XERCES + MemorySpecification memSpec(MemSpecParser::getMemSpecFromXML(filename)); +#else + MemorySpecification memSpec; +#endif + libDRAMPower test = libDRAMPower(memSpec, 0); + + ios_base::fmtflags flags = cout.flags(); + streamsize precision = cout.precision(); + cout.precision(2); + cout << fixed << endl; + + // During the simulation you can report activity + // to DRAMPower with the doCommand(...) function: + test.doCommand(MemCommand::ACT,0,35); + test.doCommand(MemCommand::RDA,0,50); + test.doCommand(MemCommand::ACT,4,51); + test.doCommand(MemCommand::RDA,4,66); + test.doCommand(MemCommand::ACT,0,86); + test.doCommand(MemCommand::RDA,0,101); + test.doCommand(MemCommand::ACT,2,102); + test.doCommand(MemCommand::RDA,2,117); + test.doCommand(MemCommand::ACT,5,119); + test.doCommand(MemCommand::RDA,5,134); + test.doCommand(MemCommand::ACT,0,137); + test.doCommand(MemCommand::RDA,0,152); + test.doCommand(MemCommand::ACT,3,159); + test.doCommand(MemCommand::RDA,3,174); + test.doCommand(MemCommand::ACT,0,195); + test.doCommand(MemCommand::RDA,0,210); + test.doCommand(MemCommand::ACT,4,232); + test.doCommand(MemCommand::WRA,4,247); + // Need at least tWRAPDEN = AL + CWL + BL/2 + WR + 1 cycles between WR and PDN_F_PRE + test.doCommand(MemCommand::PDN_F_PRE,3,265); + // Exit from Precharge Power-down + test.doCommand(MemCommand::PUP_PRE,3,300); + // Activate bank 0 + test.doCommand(MemCommand::ACT,0,350); + // Precharge all banks with bank 0 active + test.doCommand(MemCommand::PREA,0,400); + // Precharge all banks again + // XXX: For testing purpose only! Double precharge all should never + // happen. Warnings are generated. + test.doCommand(MemCommand::PREA,0,450); + // Activate bank 0 twice + // XXX: For testing purpose only! Double activate should never happen. + // Warnings are generated. + test.doCommand(MemCommand::ACT,0,500); + test.doCommand(MemCommand::ACT,0,550); + // Precharge bank 0 twice + // XXX: For testing purpose only! Double precharge for the same bank + // should never happen. Warnings are generated. + test.doCommand(MemCommand::PRE,0,600); + test.doCommand(MemCommand::PRE,0,650); - //set bool to true when this is the last update of the counters - test.updateCounters(true); + // At the end of your simulation call the getEnergy(...) + // function to print the power report + test.calcEnergy(); - // At the end of your simulation call the getEnergy(...) - // function to print the power report - test.calcEnergy(); + // Accesing the results: - // Accesing the results: + // Number of issued Commands + std::cout << "Number of ACTs: " << std::accumulate(test.counters.numberofactsBanks.begin(), + test.counters.numberofactsBanks.end() + ,0)<< endl; + std::cout << "Number of RDs: " << std::accumulate(test.counters.numberofreadsBanks.begin(), + test.counters.numberofreadsBanks.end() + ,0)<< endl; + std::cout << "Number of PREs: " << std::accumulate(test.counters.numberofpresBanks.begin(), + test.counters.numberofpresBanks.end() + ,0)<< endl; + // many other timing parameters in test.mpm.timings - // Number of issued Commands - std::cout << "# of acts" << "\t" <<test.counters.numberofacts << endl; - std::cout << "# of reads" << "\t" <<test.counters.numberofreads << endl; - std::cout << "# of precharges" << "\t" <<test.counters.numberofpres << endl; - // many other timing parameters in test.mpm.timings + //ENERGIES per Rank + std::cout << "ACT Cmd Energy: " << test.getEnergy().act_energy << " pJ" << endl; + std::cout << "PRE Cmd Energy: " << test.getEnergy().pre_energy << " pJ" << endl; + std::cout << "RD Cmd Energy: " << test.getEnergy().read_energy << " pJ" << endl; + std::cout << "WR Cmd Energy: " << test.getEnergy().write_energy << " pJ" << endl << endl; + //Standby Energy for 1 rank + //In total energy calculated for both ranks= test.memSpec.memArchSpec * + //test.getEnergy().act_stdby_energy + std::cout << "ACT Stdby Energy: " << test.getEnergy().act_stdby_energy << " pJ" << endl; + //total active standby energy for both ranks + std::cout << "ACT Stdby Energy total ranks: " << static_cast<double>(memSpec.memArchSpec.nbrOfRanks) * + test.getEnergy().act_stdby_energy << " pJ" << endl ; + std::cout << "PRE Stdby Energy: " << test.getEnergy().pre_stdby_energy << " pJ" << endl << endl; + std::cout << "Total Trace Energy: " << test.getEnergy().total_energy << " pJ" << endl; + //many other energies in test.mpm.energy - //ENERGIES per Rank - std::cout << "ACT Cmd Energy" << "\t" << test.getEnergy().act_energy << endl; - std::cout << "PRE Cmd Energy" << "\t" << test.getEnergy().pre_energy << endl; - std::cout << "Read Cmd Energy" << "\t" << test.getEnergy().read_energy << endl; - std::cout << "Write Cmd Energy" << "\t" << test.getEnergy().write_energy << endl; - //Standby Energy for 1 rank - //In total energy calculated for both ranks= test.memSpec.memArchSpec * - //test.getEnergy().act_stdby_energy - std::cout << "ACT Std Energy" << "\t" << test.getEnergy().act_stdby_energy << endl; - //total active standby energy for both ranks - std::cout << "ACT Std Energy total ranks" << "\t" << static_cast<double>(memSpec.memArchSpec.nbrOfRanks) * - test.getEnergy().act_stdby_energy << "\n" ; - std::cout << "PRE Std Energy" << "\t" << test.getEnergy().pre_stdby_energy << endl; - std::cout << "Total Energy" << "\t" << test.getEnergy().total_energy << endl; - //many other energies in test.mpm.energy + //Powers per Rank + std::cout << "Average Power: " << test.getPower().average_power << " mW" << endl; + //many other powers in test.getPower() - //Powers per Rank - std::cout << "Average Power" << "\t" << test.getPower().average_power << endl; - //many other powers in test.getPower() + cout.flags(flags); + cout.precision(precision); - // Test clearState function. - test.clearState(); - return 0; + return 0; } |