Deleted Added
sdiff udiff text old ( 10428:0caf62b57dfd ) new ( 11555:2efa95cf8504 )
full compact
1/*
2 * Copyright (c) 2014, TU Delft, TU Eindhoven and TU Kaiserslautern
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * 3. Neither the name of the copyright holder nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26 * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * Authors: Matthias Jung, Omar Naji
33 *
34 */
35
36#include <string>
37#include "libdrampower/LibDRAMPower.h"
38
39#if USE_XERCES
40 #include "xmlparser/MemSpecParser.h"
41#endif
42
43using namespace std;
44using namespace Data;
45
46int main(int argc, char* argv[])
47{
48 assert(argc == 2);
49 //Setup of DRAMPower for your simulation
50 string filename;
51 //type path to memspec file
52 filename = argv[1];
53 //Parsing the Memspec specification of found in memspec folder
54 #if USE_XERCES
55 MemorySpecification memSpec(MemSpecParser::getMemSpecFromXML(filename));
56 #else
57 MemorySpecification memSpec;
58 #endif
59 libDRAMPower test = libDRAMPower(memSpec, 0);
60 // During the simulation you can report activity
61 // to DRAMPower with the doCommand(...) function:
62 test.doCommand(MemCommand::ACT,0,35);
63 test.doCommand(MemCommand::RDA,0,50);
64 test.doCommand(MemCommand::ACT,4,51);
65 test.doCommand(MemCommand::RDA,4,66);
66 test.doCommand(MemCommand::ACT,0,86);
67 test.doCommand(MemCommand::RDA,0,101);
68 test.doCommand(MemCommand::ACT,2,102);
69 //This functionality is still not implemented.
70 test.updateCounters(false);
71 test.doCommand(MemCommand::RDA,2,117);
72 test.doCommand(MemCommand::ACT,5,119);
73 test.doCommand(MemCommand::RDA,5,134);
74 test.doCommand(MemCommand::ACT,0,137);
75 test.doCommand(MemCommand::RDA,0,152);
76 test.doCommand(MemCommand::ACT,3,159);
77 test.doCommand(MemCommand::RDA,3,174);
78 test.doCommand(MemCommand::ACT,0,195);
79 test.doCommand(MemCommand::RDA,0,210);
80 test.doCommand(MemCommand::ACT,4,232);
81 test.doCommand(MemCommand::WRA,4,247);
82 // Need at least tWRAPDEN = AL + CWL + BL/2 + WR + 1 cycles between WR and PDN_F_PRE
83 test.doCommand(MemCommand::PDN_F_PRE,3,265);
84
85 //set bool to true when this is the last update of the counters
86 test.updateCounters(true);
87
88 // At the end of your simulation call the getEnergy(...)
89 // function to print the power report
90 test.calcEnergy();
91
92 // Accesing the results:
93
94 // Number of issued Commands
95 std::cout << "# of acts" << "\t" <<test.counters.numberofacts << endl;
96 std::cout << "# of reads" << "\t" <<test.counters.numberofreads << endl;
97 std::cout << "# of precharges" << "\t" <<test.counters.numberofpres << endl;
98 // many other timing parameters in test.mpm.timings
99
100 //ENERGIES per Rank
101 std::cout << "ACT Cmd Energy" << "\t" << test.getEnergy().act_energy << endl;
102 std::cout << "PRE Cmd Energy" << "\t" << test.getEnergy().pre_energy << endl;
103 std::cout << "Read Cmd Energy" << "\t" << test.getEnergy().read_energy << endl;
104 std::cout << "Write Cmd Energy" << "\t" << test.getEnergy().write_energy << endl;
105 //Standby Energy for 1 rank
106 //In total energy calculated for both ranks= test.memSpec.memArchSpec *
107 //test.getEnergy().act_stdby_energy
108 std::cout << "ACT Std Energy" << "\t" << test.getEnergy().act_stdby_energy << endl;
109 //total active standby energy for both ranks
110 std::cout << "ACT Std Energy total ranks" << "\t" << static_cast<double>(memSpec.memArchSpec.nbrOfRanks) *
111 test.getEnergy().act_stdby_energy << "\n" ;
112 std::cout << "PRE Std Energy" << "\t" << test.getEnergy().pre_stdby_energy << endl;
113 std::cout << "Total Energy" << "\t" << test.getEnergy().total_energy << endl;
114 //many other energies in test.mpm.energy
115
116 //Powers per Rank
117 std::cout << "Average Power" << "\t" << test.getPower().average_power << endl;
118 //many other powers in test.getPower()
119
120 // Test clearState function.
121 test.clearState();
122 return 0;
123}