diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/powerInfo.xml b/DRAMSys/simulator/resources/configs/temperature_sim/powerInfo.xml new file mode 100644 index 00000000..8812a6c6 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/temperature_sim/powerInfo.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml b/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml deleted file mode 100644 index e8e086ab..00000000 --- a/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index d8ccba71..cdc39f5e 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -15,9 +15,11 @@ - + + + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index b26f1fa0..8e2b155b 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -159,14 +159,18 @@ void Configuration::setParameter(std::string name, std::string value) temperatureSim.DynTemperatureSimPeriod = std::stod(value.c_str()); else if (name == "DynTemperatureSimUnit") temperatureSim.DynTemperatureSimUnit = string2TimeUnit(value); - else if (name == "PowerThresholdsFile") { - temperatureSim.powerThresholdsFile = value; - temperatureSim.parsePowerThresholdsFile(); + else if (name == "PowerInfoFile") { + temperatureSim.powerInfoFile = value; + temperatureSim.parsePowerInfoFile(); } else if (name == "IceServerIp") temperatureSim.IceServerIp = value; else if (name == "IceServerPort") temperatureSim.IceServerPort = string2int(value); + else if (name == "SimPeriodAdjustFactor") + temperatureSim.SimPeriodAdjustFactor = std::stoi(value.c_str()); + else if (name == "NPowStableCyclesToIncreasePeriod") + temperatureSim.NPowStableCyclesToIncreasePeriod = std::stoi(value.c_str()); else { SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str()); diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h index 84e12d00..4cc9949c 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -55,29 +55,38 @@ struct TemperatureSimConfig { enum sc_time_unit DynTemperatureSimUnit; std::string IceServerIp; unsigned int IceServerPort; + unsigned int SimPeriodAdjustFactor; + unsigned int NPowStableCyclesToIncreasePeriod; - std::string powerThresholdsFile; + // Power related information + std::string powerInfoFile; + std::vector powerInitialValues; std::vector powerThresholds; - void parsePowerThresholdsFile() + void parsePowerInfoFile() { - printDebugMessage("Power Thresholds File: " + powerThresholdsFile); + printDebugMessage("Power Info File: " + powerInfoFile); // Load the XML file into memory and parse it tinyxml2::XMLDocument xml; - loadXML(powerThresholdsFile, xml); - tinyxml2::XMLElement *powThrElem = xml.FirstChildElement("power_thresholds"); + loadXML(powerInfoFile, xml); + tinyxml2::XMLElement *powInfoElem = xml.FirstChildElement("powerInfo"); - if (powThrElem == NULL) { + if (powInfoElem == NULL) { // Invalid file - std::string errormsg = "Invalid Power Thresholds File " + powerThresholdsFile; + std::string errormsg = "Invalid Power Info File " + powerInfoFile; printDebugMessage(errormsg); SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str()); throw; } - for (tinyxml2::XMLElement *e = powThrElem->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { - std::string thr_str = e->Attribute("value"); + for (tinyxml2::XMLElement *e = powInfoElem->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { + + std::string init_pow_str = e->Attribute("init_pow"); + float pow = std::stof(init_pow_str); + powerInitialValues.push_back(pow); + + std::string thr_str = e->Attribute("threshold"); float thr = std::stof(thr_str); powerThresholds.push_back(thr); } @@ -88,6 +97,10 @@ struct TemperatureSimConfig { void showTemperatureSimConfig() { int i = 0; + for (auto e : powerInitialValues) { + printDebugMessage("powerInitialValues[" + std::to_string(i++) + "]: " + std::to_string(e)); + } + i = 0; for (auto e : powerThresholds) { printDebugMessage("powerThreshold[" + std::to_string(i++) + "]: " + std::to_string(e)); } diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index ac859a93..d2dc0129 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -495,6 +495,9 @@ unsigned int errorModel::getBit(int row, int column, int byteInColumn, int bitIn double errorModel::getTemperature() { + // TODO here we need to get the current power value from DRAMPower (and + // make adjusts if necessary) and pass it to the Temperature Controller + // with the correct ID for this device. double temperature = TemperatureController::getInstance().getTemperature(0, 0); return temperature; } diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index de2b6dab..a740deba 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -42,8 +42,9 @@ double TemperatureController::getTemperature(int deviceId, float currentPower) { if (dynamicTempSimEnabled == true) { - // XXX do I need a mutex here? currentPowerValues.at(deviceId) = currentPower; + if (temperatureValues.empty()) + return staticTemperature; return temperatureValues.at(deviceId); } else { printDebugMessage("Temperature is " + std::to_string(staticTemperature)); @@ -85,7 +86,7 @@ double TemperatureController::adjustThermalSimPeriod() // defined in the configuration by the user. // // 1.2.1 The situation period will be kept for a number of simulation - // executions 'ne' and after ne' the period will be increased again in + // executions 'ne' and after 'ne' the period will be increased again in // steps of 'n/2' until it achieves the desired value given by // configuration or the described in 1.1 occurs. diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 4b9ee481..19ef7674 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -59,53 +59,24 @@ public: dynamicTempSimEnabled = Configuration::getInstance().DynamicTemperatureSimulation; if (dynamicTempSimEnabled == true) { - + // Connect to the server std::string ip = Configuration::getInstance().temperatureSim.IceServerIp; unsigned int port = Configuration::getInstance().temperatureSim.IceServerPort; thermalSimulation = new IceWrapper(ip, port); printDebugMessage("Dynamic temperature simulation. Server @ " + ip + ":" + std::to_string(port)); - // get from config the initial power dissipation value - currentPowerValues = { - 0, // 1: CPUs - 0, // 2: GPU - 1, // 3: BASEBAND1 - 0, // 4: BASEBAND2 - 0, // 5: LLCACHE - 0, // 6: DRAMCTRL1 - 0, // 7: DRAMCTRL2 - 0, // 8: TSVs - 0, // 9: ACELLERATORS - 1, //10: C0 - 0, //11: C1 - 0, //12: C2 - 0, //13: C3 - 0, //14: TSVs - 0, //10: C0 - 0, //11: C1 - 0, //12: C2 - 0, //13: C3 - 0, //14: TSVs - 0, //10: C0 - 0, //11: C1 - 0, //12: C2 - 0, //13: C3 - 0, //14: TSVs - 0, //10: C0 - 0, //11: C1 - 0, //12: C2 - 0, //13: C3 - 0 //14: TSVs - }; - + // Initial power dissipation values (got from config) + currentPowerValues = Configuration::getInstance().temperatureSim.powerInitialValues; lastPowerValues = currentPowerValues; + // Substantial changes in power will trigger adjustments in the simulaiton period. Get the thresholds from config. powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds; - periodAdjustFactor = 10; - nPowStableCyclesToIncreasePeriod = 5; + periodAdjustFactor = Configuration::getInstance().temperatureSim.SimPeriodAdjustFactor; + nPowStableCyclesToIncreasePeriod = Configuration::getInstance().temperatureSim.NPowStableCyclesToIncreasePeriod; cyclesSinceLastPeriodAdjust = 0; + // Get the target period for the thermal simulation from config. targetPeriod = Configuration::getInstance().temperatureSim.DynTemperatureSimPeriod; period = targetPeriod; t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; diff --git a/README.md b/README.md index 47c750d7..85932202 100644 --- a/README.md +++ b/README.md @@ -140,9 +140,11 @@ The XML code below shows a typic configuration: - + + + @@ -258,12 +260,16 @@ Below are listed the configuration sections and configuration fields. - "ns": nanoseconds - "ps": picoseconds - "fs": femtoseconds - - *PowerThresholdsFile* (string) - - File containing the power thresholds that trigger the temperature simulation + - *PowerInfoFile* (string) + - File containing power related information: devices identifiers, initial power values and power thresholds. - *IceServerIp* (string) - 3D-Ice server IP address - *IceServerPort* (unsigned int) - 3D-Ice server port + - *SimPeriodAdjustFactor* (unsigned int) + - When substantial changes in power occur (i.e., changes that exceed the thresholds), then the simulation period will be divided by this number causing the thermal simulation to be executed more often. + - *NPowStableCyclesToIncreasePeriod* (unsigned int) + - Wait this number of thermal simulation executions or cycles with power stability (i.e., changes that do not exceed the thresholds) to start increasing the simulation period back to its configured value. - **Memory Specification**