From b2fcde07cf2a7798e71467acdb8a3c4d7899feec Mon Sep 17 00:00:00 2001 From: sprado Date: Mon, 14 Mar 2016 16:03:08 +0100 Subject: [PATCH 1/2] Power over time --- DRAMSys/analyzer/scripts/plots.py | 11 +++++---- DRAMSys/simulator/src/simulation/Dram.h | 31 +++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/DRAMSys/analyzer/scripts/plots.py b/DRAMSys/analyzer/scripts/plots.py index fd4818ea..5eb3b463 100644 --- a/DRAMSys/analyzer/scripts/plots.py +++ b/DRAMSys/analyzer/scripts/plots.py @@ -17,9 +17,9 @@ def plot(function): def memory_utilisation_window(connection, tracePath): # This function determines the average memory bandwidth over time in percentage and in Gbit/s. # The average bandwidth over time is done dividing the time into windows of the same length and getting the average bandwidth in each window. - # Through the data from the database, DataStrobeEnd and DataStrobeBegin, it is possible to assess when a data transfer begins or ends. - # Hence, it is possible to ckeck when a data transfer happens and if it occupies or is inside a time window. Then, it is possible to determine the average bandwidth in percentage. - # Besides, extracting the data from the memory specs, it is possible to calculate the maximum data rate of the memory and then determine the bandwidth in Gbit/s. + # Through data from the database, DataStrobeEnd and DataStrobeBegin, it is possible to assess when a data transfer begins or ends. + # Hence, it is achievable to ckeck when a data transfer happens and if it occupies or is inside a time window. Then, it is attainable to determine the average bandwidth in percentage. + # Besides, extracting the data from the memory specs, it is feasible to calculate the maximum data rate of the memory and then determine the bandwidth in Gbit/s. # The bandwidth data are then plotted in two graphics. steps = 1000 @@ -28,7 +28,7 @@ def memory_utilisation_window(connection, tracePath): total = cursor.fetchone() windowSize = ceil(float(total[0])/float(steps)) if (windowSize == 0): - windowSize = 1 + windowSize = 1 # print(steps) # All possible cases of data transfers inside a time window queryFull = """ SELECT sum(DataStrobeEnd - DataStrobeBegin) FROM transactions Where DataStrobeBegin > ? and DataStrobeEnd < ?""" # The data transfer begins and ends inside the time window @@ -101,6 +101,7 @@ def memory_utilisation_window(connection, tracePath): pdf = PdfPages(OUTPUT_FILE) pdf.savefig() pdf.close() + return # @plot @@ -117,7 +118,7 @@ def memory_utilisation_window(connection, tracePath): # return "Saved as hist.png" -def generatePlots(pathToTrace): +def generatePlots(pathToTrace): connection = sqlite3.connect(pathToTrace) print("================================") diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index 856899f2..acb07ecd 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -67,7 +67,10 @@ struct Dram : sc_module // Power Model related bool powerAnalysis = Configuration::getInstance().PowerAnalysis; + sc_time windowSize = sc_time(1000,SC_NS); libDRAMPower * DRAMPower; + double totalEnergy = 0; + // Error Model related: ErrorStorageMode ErrorStoreMode = Configuration::getInstance().ErrorStoreMode; @@ -86,7 +89,7 @@ struct Dram : sc_module if(powerAnalysis == true) { sc_time clk = Configuration::getInstance().memSpec.clk; - + MemArchitectureSpec memArchSpec; memArchSpec.burstLength = Configuration::getInstance().memSpec.BurstLength; memArchSpec.dataRate = Configuration::getInstance().memSpec.DataRate; @@ -164,6 +167,7 @@ struct Dram : sc_module memSpec.memArchSpec = memArchSpec; DRAMPower = new libDRAMPower( memSpec, 0 ); + SC_THREAD(window); } printDebugMessage(string("ErrorStorageMode: ") + EnumToString(ErrorStoreMode)); @@ -189,8 +193,10 @@ struct Dram : sc_module { DRAMPower->updateCounters(true); DRAMPower->calcEnergy(); + printDebugMessage(string("\tCurrent Energy: \t") + to_string(DRAMPower->getEnergy().total_energy - totalEnergy)); + printDebugMessage(string("\tAverage Power: \t") + to_string((DRAMPower->getEnergy().total_energy - totalEnergy)/windowSize.value())); cout << name() << string("\tTotal Energy: \t") + to_string(DRAMPower->getEnergy().total_energy) << endl; - cout << name() << string("\tAverage Power: \t") + to_string(DRAMPower->getPower().average_power) << endl; + cout << name() << string("\tAverage Power: \t") + to_string(DRAMPower->getPower().average_power) << endl; } // Clean up: for (auto e : ememory) { @@ -198,6 +204,27 @@ struct Dram : sc_module } //std::cout << "Simulated Memory Size: " << memory.size() << endl; // TODO Aufrauemen } + + void window() + { + double currentAveragePower = 0; + double currentTotalEnergy = 0; + + do + { + DRAMPower->updateCounters(false); + DRAMPower->calcEnergy(); + currentTotalEnergy = DRAMPower->getEnergy().total_energy - totalEnergy; + currentAveragePower = currentTotalEnergy/windowSize.value(); + totalEnergy = DRAMPower->getEnergy().total_energy; + + printDebugMessage(string("\tCurrent Energy: \t") + to_string(currentTotalEnergy)); + printDebugMessage(string("\tAverage Power: \t") + to_string(currentAveragePower)); + wait(windowSize); + } + while(true); + + } virtual tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& payload, tlm::tlm_phase& phase, sc_time& delay) { From 99a623690aa09663a8a444b0a08765214ea2de15 Mon Sep 17 00:00:00 2001 From: sprado Date: Tue, 15 Mar 2016 21:39:39 +0100 Subject: [PATCH 2/2] cout lines removed --- DRAMSys/simulator/src/simulation/Dram.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index acb07ecd..dda5b998 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -167,7 +167,7 @@ struct Dram : sc_module memSpec.memArchSpec = memArchSpec; DRAMPower = new libDRAMPower( memSpec, 0 ); - SC_THREAD(window); + SC_THREAD(powerWindow); } printDebugMessage(string("ErrorStorageMode: ") + EnumToString(ErrorStoreMode)); @@ -194,9 +194,7 @@ struct Dram : sc_module DRAMPower->updateCounters(true); DRAMPower->calcEnergy(); printDebugMessage(string("\tCurrent Energy: \t") + to_string(DRAMPower->getEnergy().total_energy - totalEnergy)); - printDebugMessage(string("\tAverage Power: \t") + to_string((DRAMPower->getEnergy().total_energy - totalEnergy)/windowSize.value())); - cout << name() << string("\tTotal Energy: \t") + to_string(DRAMPower->getEnergy().total_energy) << endl; - cout << name() << string("\tAverage Power: \t") + to_string(DRAMPower->getPower().average_power) << endl; + printDebugMessage(string("\tAverage Power: \t") + to_string((DRAMPower->getEnergy().total_energy - totalEnergy)/windowSize.value())); } // Clean up: for (auto e : ememory) { @@ -205,7 +203,7 @@ struct Dram : sc_module //std::cout << "Simulated Memory Size: " << memory.size() << endl; // TODO Aufrauemen } - void window() + void powerWindow() { double currentAveragePower = 0; double currentTotalEnergy = 0;