From d039e4fc19e00b52e4b03693cff238790416e339 Mon Sep 17 00:00:00 2001 From: "Felipe S. Prado" Date: Mon, 24 Oct 2016 20:06:23 +0200 Subject: [PATCH] LibDRAMPower Update --- DRAMSys/simulator/src/error/errormodel.cpp | 4 +- DRAMSys/simulator/src/simulation/Dram.h | 48 ++++------------------ 2 files changed, 10 insertions(+), 42 deletions(-) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index f67f5544..36dc98ba 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -524,8 +524,8 @@ double errorModel::getTemperature() if (thermalSim == true && powerAnalysis == true) { // TODO // check if this is best way to request information to DRAMPower. - DRAMPower->updateCounters(true); - DRAMPower->calcEnergy(); + unsigned long long clk_cycles = sc_time_stamp().value() / Configuration::getInstance().memSpec.clk.value(); + DRAMPower->calcWindowEnergy(clk_cycles); float average_power = (float)DRAMPower->getPower().average_power; temperature = TemperatureController::getInstance().getTemperature(this->myChannel, average_power); } else { diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index bb4a3d2b..7db71f78 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -76,7 +76,6 @@ struct Dram : sc_module bool powerAnalysis = Configuration::getInstance().PowerAnalysis; sc_time powerWindowSize = Configuration::getInstance().memSpec.clk*Configuration::getInstance().WindowSize; libDRAMPower *DRAMPower; - double sumOfEnergyWindows = 0.0; // Bandwidth realted: unsigned long long int numberOfTransactionsServed; @@ -217,18 +216,13 @@ struct Dram : sc_module { if (powerAnalysis == true) { // Obtain the residual energy which was not covered by previous windows - DRAMPower->updateCounters(true); DRAMPower->calcEnergy(); - double totalEnergy = sumOfEnergyWindows + DRAMPower->getEnergy().total_energy * Configuration::getInstance().NumberOfDevicesOnDIMM; - // The energy is given in [pJ] and divided by [s] resulting in [pW] then converted to [mW] - double averagePower = (totalEnergy/ sc_time_stamp().to_seconds()) / 1e9; - - tlmRecorder->recordPower(sc_time_stamp().to_seconds(), DRAMPower->getPower().average_power * Configuration::getInstance().NumberOfDevicesOnDIMM); + tlmRecorder->recordPower(sc_time_stamp().to_seconds(), DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM); // Print the final total energy and the average power for the simulation - cout << name() << string("\tTotal Energy: \t") << fixed <getEnergy().total_energy * Configuration::getInstance().NumberOfDevicesOnDIMM << string(" pJ") << endl; + cout << name() << string("\tAverage Power: \t") << fixed <getPower().average_power * Configuration::getInstance().NumberOfDevicesOnDIMM<< string(" mW") << endl; } // Bandwidth: @@ -265,8 +259,6 @@ struct Dram : sc_module // It estimates the current average power which will be stored in the trace database for visualization purposes. void powerWindow() { - double currentAveragePower = 0; - double currentTotalEnergy = 0; unsigned long long clk_cycles = 0; do { @@ -275,41 +267,17 @@ struct Dram : sc_module clk_cycles = sc_time_stamp().value() / Configuration::getInstance().memSpec.clk.value(); - DRAMPower->doCommand(MemCommand::NOP, 0, clk_cycles); - DRAMPower->updateCounters(false); - DRAMPower->calcEnergy(); - - currentTotalEnergy = DRAMPower->getEnergy().total_energy * Configuration::getInstance().NumberOfDevicesOnDIMM; - currentAveragePower = DRAMPower->getPower().average_power * Configuration::getInstance().NumberOfDevicesOnDIMM; - - DRAMPower->clearCounters(clk_cycles); + DRAMPower->calcWindowEnergy(clk_cycles); // During operation the energy should never be zero since the device is always consuming - assert(!is_equal(currentTotalEnergy, 0.0)); - - // Accumulate the energy since we are clearing the library - // counters. - // - // Here we use double values. The double type ensures 15 decimal - // digits to represent a number. It does not matter if the digits - // are before or after the comma. Thus we only have rounding for - // numbers represented with more than 15 decimal digits. - // - // In more technical terms: - // An IEEE double has 53 significant bits (see also DBL_MANT_DIG - // in ). That is approximately 15.95 decimal digits - // (log10(2^53)). The implementation sets the number of digits - // (DBL_DIG) to 15, not 16, because it has to round down. - // - - sumOfEnergyWindows += currentTotalEnergy; + assert(!is_equal(DRAMPower->getEnergy().window_energy, 0.0)); // Store the time (in seconds) and the current average power (in mW) into the database - tlmRecorder->recordPower(sc_time_stamp().to_seconds(), currentAveragePower); + tlmRecorder->recordPower(sc_time_stamp().to_seconds(), DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM); // Here considering that DRAMPower provides the energy in pJ and the power in mW - printDebugMessage(string("\tCurrent Energy: \t") + to_string(currentTotalEnergy) + string("\t[pJ]")); - printDebugMessage(string("\tAverage Power: \t") + to_string(currentAveragePower) + string("\t[mW]")); + printDebugMessage(string("\tWindow Energy: \t") + to_string(DRAMPower->getEnergy().window_energy * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[pJ]")); + printDebugMessage(string("\tWindow Average Power: \t") + to_string(DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[mW]")); } while(true); }