From ef975f52ea455b922f668e1d564e3f28249a8e08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 23 Sep 2015 15:55:56 +0200 Subject: [PATCH 01/39] Added dram.vp.icewrapper as a submodule --- .gitmodules | 3 +++ DRAMSys/simulator/src/common/third_party/icewrapper | 1 + 2 files changed, 4 insertions(+) create mode 160000 DRAMSys/simulator/src/common/third_party/icewrapper diff --git a/.gitmodules b/.gitmodules index 7aed65f9..b2cd2b65 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "DRAMSys/simulator/src/common/third_party/tinyxml2"] path = DRAMSys/simulator/src/common/third_party/tinyxml2 url = https://github.com/leethomason/tinyxml2.git +[submodule "DRAMSys/simulator/src/common/third_party/icewrapper"] + path = DRAMSys/simulator/src/common/third_party/icewrapper + url = git@git.rhrk.uni-kl.de:EIT-Wehn/dram.vp.icewrapper.git diff --git a/DRAMSys/simulator/src/common/third_party/icewrapper b/DRAMSys/simulator/src/common/third_party/icewrapper new file mode 160000 index 00000000..e84ff691 --- /dev/null +++ b/DRAMSys/simulator/src/common/third_party/icewrapper @@ -0,0 +1 @@ +Subproject commit e84ff691e99f7ed246ac85b76906961b061aaaf8 From 65e52d0e75e291902f1c8348e4c961549cd88f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 24 Sep 2015 17:39:37 +0200 Subject: [PATCH 02/39] DRAMSys and IceWrapper projects integrated. --- DRAMSys/dram.vp.system.pro | 5 ++++- DRAMSys/simulator/simulator.pro | 12 ++++++++++++ README.md | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/DRAMSys/dram.vp.system.pro b/DRAMSys/dram.vp.system.pro index 3db74aa5..d1a3d29f 100644 --- a/DRAMSys/dram.vp.system.pro +++ b/DRAMSys/dram.vp.system.pro @@ -1,5 +1,8 @@ TEMPLATE = subdirs -SUBDIRS = simulator/simulator.pro +SUBDIRS = simulator/src/common/third_party/icewrapper/3D-ICE-SystemC-Client.pro +SUBDIRS += simulator/simulator.pro SUBDIRS += analyzer/traceAnalyzer.pro +# build the project sequentially as listed in SUBDIRS +CONFIG += ordered diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index 483de244..bc42aecc 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -131,3 +131,15 @@ HEADERS += \ src/controller/core/configuration/ConfigurationLoader.h \ src/error/errormodel.h + +LIBS += -L/opt/3D-ICE/lib -lthreed-ice-2.2.5 +LIBS += -L/opt/SuperLU_4.3/lib -lsuperlu_4.3 +LIBS += -lblas + +INCLUDEPATH += /opt/3D-ICE/include +INCLUDEPATH += /opt/SuperLU_4.3/SRC +INCLUDEPATH += /opt/systemc/include +INCLUDEPATH += src/common/third_party/icewrapper + +OBJECTS += $$(PWD)/src/common/third_party/icewrapper/IceWrapper.o + diff --git a/README.md b/README.md index 2536877b..e64630dd 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,9 @@ $ git clone --recursive https://@git.rhrk.uni-kl.de/EIT-Wehn/dram.vp.syste ``` The *--recursive* flag tells git to initialize all submodules within the -repository. **DRAMPower** [2] and **tinyxml** are examples third party -repositories that were embedded within the source tree as submodules. +repository. **DRAMPower** [2], **tinyxml** and **icewrapper** are examples +third party repositories that were embedded within the source tree as +submodules. It is possible to work with a **fork** of the official codebase. In that case, after pushing changes into your fork you should create a **pull request** in From 3c809a2853c55dc8c818f2269f5da9315e263459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 24 Sep 2015 18:23:40 +0200 Subject: [PATCH 03/39] New configuration option: DynamicTemperatureSimulation --- .../resources/simulations/sim-batch.xml | 9 ++++++++ .../core/configuration/Configuration.cpp | 2 ++ .../core/configuration/Configuration.h | 1 + DRAMSys/simulator/src/error/errormodel.cpp | 21 +++++++++++++++++-- DRAMSys/simulator/src/error/errormodel.h | 2 ++ README.md | 4 ++++ 6 files changed, 37 insertions(+), 2 deletions(-) diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 8a9f9407..437a73a1 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -6,6 +6,7 @@ + @@ -25,5 +26,13 @@ chstone-adpcm_32.stl + + + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 4d5ccf36..8395c250 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -123,6 +123,8 @@ void Configuration::setParameter(std::string name, std::string value) NumberOfMemChannels = string2int(value); else if (name == "ControllerCoreDisableRefresh") ControllerCoreDisableRefresh = string2bool(value); + else if (name == "DynamicTemperatureSimulation") + DynamicTemperatureSimulation = string2bool(value); // Specification for ErrorChipSeed, ErrorCSVFile path and ErrorStoreMode else if(name == "ErrorChipSeed") ErrorChipSeed = string2int(value); diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index c88e08c2..905bfb75 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -78,6 +78,7 @@ struct Configuration unsigned int NumberOfTracePlayers = 1; unsigned int NumberOfMemChannels = 1; bool ControllerCoreDisableRefresh = false; + bool DynamicTemperatureSimulation = false; //MemSpec(from DRAM-Power XML) MemSpec memSpec; diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 1fe29ccb..831387e1 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -42,6 +42,7 @@ errorModel::errorModel() { // Get Configuration parameters: + dynamicTemepratureSimulation = Configuration::getInstance().DynamicTemperatureSimulation; busWidth = Configuration::getInstance().Buswidth; burstLenght = Configuration::getInstance().memSpec.BurstLength; numberOfColumns = Configuration::getInstance().memSpec.NumberOfColumns; @@ -49,6 +50,7 @@ errorModel::errorModel() numberOfRows = Configuration::getInstance().memSpec.NumberOfRows; numberOfBitErrorEvents = 0; + // Initialize the lastRow Access array: lastRowAccess = new sc_time[numberOfRows]; for(unsigned int i = 0; i < numberOfRows; i++) @@ -101,7 +103,10 @@ errorModel::errorModel() //weakCells[0].row = 0; //weakCells[0].dependent = true; - setTemperature(89); + if (dynamicTemepratureSimulation == false) { + setTemperature(89); + } + markBitFlips(); } @@ -229,6 +234,7 @@ void errorModel::load(tlm::tlm_generic_payload &trans) void errorModel::markBitFlips() { + double temp = getTemperature(); for(unsigned int row = 0; row < Configuration::getInstance().memSpec.NumberOfRows; row++) { // If the row has never been accessed ignore it and go to the next one @@ -238,7 +244,7 @@ void errorModel::markBitFlips() sc_time interval = sc_time_stamp() - lastRowAccess[row]; // Obtain the number of bit flips for the current temperature and the time interval: - unsigned int n = getNumberOfFlips(temperature, interval); + unsigned int n = getNumberOfFlips(temp, interval); // Check if the current row is in the range of bit flips for this interval // and temperature, if yes mark it as flipped: @@ -494,6 +500,17 @@ void errorModel::setTemperature(double t) temperature = t; } +double errorModel::getTemperature() +{ + if (dynamicTemepratureSimulation == true) { + // TODO Get temperature from 3d-ice simulator or other temperature source + // TODO Check all the criterion before requesting the temperature + return temperature; + } + + return temperature; +} + void errorModel::parseInputData() { std::string fileName = Configuration::getInstance().ErrorCSVFile; diff --git a/DRAMSys/simulator/src/error/errormodel.h b/DRAMSys/simulator/src/error/errormodel.h index 9bcfd54c..aac91278 100644 --- a/DRAMSys/simulator/src/error/errormodel.h +++ b/DRAMSys/simulator/src/error/errormodel.h @@ -52,6 +52,7 @@ class errorModel void refresh(unsigned int row); void activate(unsigned int row); void setTemperature(double t); + double getTemperature(void); private: // Configuration Parameters: @@ -60,6 +61,7 @@ class errorModel unsigned int numberOfColumns; unsigned int bytesPerColumn; unsigned int numberOfRows; + bool dynamicTemepratureSimulation; // Name: std::string name; diff --git a/README.md b/README.md index e64630dd..566dd265 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ The XML code below shows a typic configuration: + @@ -231,6 +232,9 @@ Below are listed the configuration sections and configuration fields. - *ControllerCoreDisableRefresh* (boolean) - "1": disables refreshes - "0": normal operation (refreshes enabled) + - *DynamicTemperatureSimulation* (boolean) + - "1": enables the dynamic temperature simulation feature + - "0": static temperature during simulation - **Memory specification** From ae6e1e1040f0185a8df770018321b30dc9ea5df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 29 Sep 2015 12:56:30 +0200 Subject: [PATCH 04/39] Get parameters related to temperature simulation from configuration --- .../resources/simulations/sim-batch.xml | 18 +++++++----- .../core/configuration/Configuration.cpp | 27 ++++++++++++++++++ .../core/configuration/Configuration.h | 5 ++++ .../configuration/ConfigurationLoader.cpp | 24 ++++++++++++++++ .../core/configuration/ConfigurationLoader.h | 6 +++- DRAMSys/simulator/src/error/errormodel.cpp | 8 +++++- .../simulator/src/simulation/Simulation.cpp | 1 + DRAMSys/simulator/src/simulation/Simulation.h | 7 +++-- .../src/simulation/SimulationManager.cpp | 4 ++- README.md | 28 ++++++++++++++++--- 10 files changed, 111 insertions(+), 17 deletions(-) diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 437a73a1..d915fe1c 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -1,4 +1,5 @@ + @@ -9,6 +10,16 @@ + + + + + + + + @@ -27,12 +38,5 @@ - - diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 8395c250..e941e65e 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -87,6 +87,26 @@ EPowerDownMode string2PDNMode(string s) } } +enum sc_time_unit string2TimeUnit(string s) +{ + if (s == "s") + return SC_SEC; + else if (s == "ms") + return SC_MS; + else if (s == "us") + return SC_US; + else if (s == "ns") + return SC_NS; + else if (s == "ps") + return SC_PS; + else if (s == "fs") + return SC_FS; + else { + SC_REPORT_FATAL("Configuration", ("Could not convert to enum sc_time_unit: " + s).c_str()); + throw; + } +} + void Configuration::setParameter(std::string name, std::string value) { if(name == "BankwiseLogic") @@ -132,6 +152,13 @@ void Configuration::setParameter(std::string name, std::string value) ErrorCSVFile = value; else if(name == "ErrorStoreMode") ErrorStoreMode = StringToEnum(value); + // Temperature Simulation related + else if (name == "StaticTemperatureDefaultValue") + StaticTemperatureDefaultValue = string2int(value); + else if (name == "DynTemperatureSimPeriod") + DynTemperatureSimPeriod = string2int(value); + else if (name == "DynTemperatureSimUnit") + DynTemperatureSimUnit = string2TimeUnit(value); else { SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str()); diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 905bfb75..562b05e7 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -91,6 +91,11 @@ struct Configuration std::string ErrorCSVFile ="not defined."; ErrorStorageMode ErrorStoreMode; + // Temperature Simulation related + int StaticTemperatureDefaultValue; + unsigned int DynTemperatureSimPeriod; + enum sc_time_unit DynTemperatureSimUnit; + private: Configuration(); unsigned int powerDownTimeoutInClk = 3; diff --git a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp index bf4166d4..b1a3a494 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.cpp @@ -62,6 +62,22 @@ void ConfigurationLoader::loadSimConfig(Configuration& config, XMLElement* simco loadConfig(config, simconfig); } +void ConfigurationLoader::loadTemperatureSimConfig(Configuration &config, std::string temperature_simconfigUri) +{ + loadConfigFromUri(config, temperature_simconfigUri, "temperature_simconfig"); +} + +void ConfigurationLoader::loadTemperatureSimConfig(Configuration &config, XMLElement *temperature_simconfig) +{ + if (temperature_simconfig->Attribute("src")) { + // Configuration is inside another a file + std::string uri(temperature_simconfig->Attribute("src")); + loadConfigFromUri(config, uri, "temperature_simconfig"); + } else { + loadConfig(config, temperature_simconfig); + } +} + void ConfigurationLoader::loadConfig(Configuration& config, XMLElement* configNode) { XMLElement* element; @@ -73,6 +89,14 @@ void ConfigurationLoader::loadConfig(Configuration& config, XMLElement* configNo } } +void ConfigurationLoader::loadConfigFromUri(Configuration &config, std::string uri, std::string first_element) +{ + tinyxml2::XMLDocument doc; + loadXML(uri, doc); + XMLElement *e = doc.FirstChildElement(first_element.c_str()); + loadConfig(config, e); +} + void ConfigurationLoader::loadMemSpec(Configuration& config, string memspecUri) { tinyxml2::XMLDocument doc; diff --git a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h index 12b30667..46bab656 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h +++ b/DRAMSys/simulator/src/controller/core/configuration/ConfigurationLoader.h @@ -46,16 +46,20 @@ class ConfigurationLoader { public: static void loadMemConfig(Configuration& config, std::string memconfigUri); - static void loadSimConfig(Configuration& config, std::string simconfigUri); static void loadMemConfig(Configuration& config, tinyxml2::XMLElement* memconfig); + + static void loadSimConfig(Configuration& config, std::string simconfigUri); static void loadSimConfig(Configuration& config,tinyxml2::XMLElement* simconfig); static void loadMemSpec(Configuration& config, std::string memspecUri); static void loadMemSpec(Configuration& config, tinyxml2::XMLElement* memspec); + static void loadTemperatureSimConfig(Configuration &config, std::string simconfigUri); + static void loadTemperatureSimConfig(Configuration& config, tinyxml2::XMLElement *simconfig); private: ConfigurationLoader(){} static void loadConfig(Configuration& config, tinyxml2::XMLElement* configNode); + static void loadConfigFromUri(Configuration &config, std::string uri, std::string first_element); //specific loader static void loadDDR3(Configuration& config, tinyxml2::XMLElement* memspec); diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 831387e1..30891f00 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -103,9 +103,15 @@ errorModel::errorModel() //weakCells[0].row = 0; //weakCells[0].dependent = true; + std::stringstream msg; if (dynamicTemepratureSimulation == false) { - setTemperature(89); + int temperature = Configuration::getInstance().StaticTemperatureDefaultValue; + setTemperature(temperature); + msg << "Static temperature simulation. Temperature set to " << temperature << std::endl; + } else { + msg << "Dynamic temperature simulation." << std::endl; } + DebugManager::getInstance().printDebugMessage(name, msg.str()); markBitFlips(); } diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index d036e4d9..932a3912 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -62,6 +62,7 @@ Simulation::Simulation(sc_module_name __attribute__((unused)) name, string pathT ConfigurationLoader::loadMemConfig(Configuration::getInstance(), setup.memconfig);//pathToResources + string("configs/memconfigs/") + setup.memconfig); ConfigurationLoader::loadMemSpec(Configuration::getInstance(), setup.memspec);//pathToResources + string("configs/memspecs/") + setup.memspec); ConfigurationLoader::loadSimConfig(Configuration::getInstance(), setup.simconfig); + ConfigurationLoader::loadTemperatureSimConfig(Configuration::getInstance(), setup.temperature_simconfig); instantiateModules(traceName, pathToResources, devices); bindSockets(); diff --git a/DRAMSys/simulator/src/simulation/Simulation.h b/DRAMSys/simulator/src/simulation/Simulation.h index 560dd289..c0bceb40 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.h +++ b/DRAMSys/simulator/src/simulation/Simulation.h @@ -53,13 +53,14 @@ struct DramSetup { - DramSetup():memspec(NULL),memconfig(NULL),simconfig(NULL),addressmapping(NULL){} - DramSetup(tinyxml2::XMLElement* memspec, tinyxml2::XMLElement* memconfig, tinyxml2::XMLElement* simconfig, tinyxml2::XMLElement* addressmapping) - : memspec(memspec), memconfig(memconfig), simconfig(simconfig), addressmapping(addressmapping) {} + DramSetup():memspec(NULL),memconfig(NULL),simconfig(NULL),addressmapping(NULL), temperature_simconfig(NULL) {} + DramSetup(tinyxml2::XMLElement* memspec, tinyxml2::XMLElement* memconfig, tinyxml2::XMLElement* simconfig, tinyxml2::XMLElement* addressmapping, tinyxml2::XMLElement *tsc) + : memspec(memspec), memconfig(memconfig), simconfig(simconfig), addressmapping(addressmapping), temperature_simconfig(tsc) {} tinyxml2::XMLElement* memspec; tinyxml2::XMLElement* memconfig; tinyxml2::XMLElement* simconfig; tinyxml2::XMLElement* addressmapping; + tinyxml2::XMLElement* temperature_simconfig; }; struct Device diff --git a/DRAMSys/simulator/src/simulation/SimulationManager.cpp b/DRAMSys/simulator/src/simulation/SimulationManager.cpp index 67285dbe..b706743e 100644 --- a/DRAMSys/simulator/src/simulation/SimulationManager.cpp +++ b/DRAMSys/simulator/src/simulation/SimulationManager.cpp @@ -100,6 +100,8 @@ void SimulationManager::parseSimulationBatch(XMLElement* simulation) XMLElement* simconfig = simulation->FirstChildElement("simconfig"); + XMLElement *temperature_simconfig = simulation->FirstChildElement("temperature_simconfig"); + XMLElement* memspecs = simulation->FirstChildElement("memspecs"); if(memspecs == NULL) memspecs = simulation; @@ -120,7 +122,7 @@ void SimulationManager::parseSimulationBatch(XMLElement* simulation) for (XMLElement* memconfig = memconfigs->FirstChildElement("memconfig"); memconfig != NULL; memconfig = memconfig->NextSiblingElement("memconfig")) { - batch.dramSetups.push_back(DramSetup(memspec, memconfig, simconfig, addressmapping)); + batch.dramSetups.push_back(DramSetup(memspec, memconfig, simconfig, addressmapping, temperature_simconfig)); } } } diff --git a/README.md b/README.md index 566dd265..2ba6dbb1 100644 --- a/README.md +++ b/README.md @@ -124,7 +124,7 @@ The XML code below shows a typic configuration: ``` xml - + @@ -135,6 +135,13 @@ The XML code below shows a typic configuration: + + + + + + + @@ -215,7 +222,7 @@ simulation. Below are listed the configuration sections and configuration fields. -- **Simulator configuration** +- **Simulator Configuration** - *Debug* (boolean) - "1": enables debug output on console - "0": disables debug output @@ -236,7 +243,20 @@ Below are listed the configuration sections and configuration fields. - "1": enables the dynamic temperature simulation feature - "0": static temperature during simulation -- **Memory specification** +- **Temperature Simulator Configuration** + - *StaticTemperatureDefaultValue* (int) + - Temperature value for simulations with static temperature + - *DynTemperatureSimPeriod* (unsigned int) + - Period of the dynamic temperature simulation + - *DynTemperatureSimUnit* (string) + - "s": seconds + - "ms": millisecond + - "us": microseconds + - "ns": nanoseconds + - "ps": picoseconds + - "fs": femtoseconds + +- **Memory Specification** A file with memory specifications. This information comes from datasheet and usually does not change. @@ -329,7 +349,7 @@ Below are listed the configuration sections and configuration fields. - "Store": store data without error model - "ErrorModel": store data with error model [6] -- **Trace setups** +- **Trace Setups** - *id* (string) - Trace setup id. Two kinds of output files are generated by DRAMSys: SQLite databases containing transactions related to each memory channel From 1160f575dc57e4db3d048524c9b56f3e3e656b92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 29 Sep 2015 17:39:17 +0200 Subject: [PATCH 05/39] Get power thresholds for temperature simulation from a xml file --- .../temperature_sim/power_thresholds.xml | 8 ++ .../resources/simulations/sim-batch.xml | 4 +- DRAMSys/simulator/simulator.pro | 1 + .../core/configuration/Configuration.cpp | 11 +- .../core/configuration/Configuration.h | 5 +- .../core/configuration/temperatureSimConfig.h | 106 ++++++++++++++++++ DRAMSys/simulator/src/error/errormodel.cpp | 2 +- DRAMSys/tests/error/sim-batch.xml | 10 ++ 8 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml create mode 100644 DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml b/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml new file mode 100644 index 00000000..c3ade839 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index d915fe1c..1ab6a01e 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -15,9 +15,7 @@ - + diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index bc42aecc..4109ea70 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -116,6 +116,7 @@ HEADERS += \ src/controller/scheduler/readwritegrouper.h \ src/simulation/ReorderBuffer.h \ src/controller/core/configuration/MemSpec.h \ + src/controller/core/configuration/temperatureSimConfig.h \ src/simulation/StlPlayer.h \ src/simulation/StlDataPlayer.h \ src/simulation/TracePlayerListener.h \ diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index e941e65e..b8671bbb 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -154,11 +154,15 @@ void Configuration::setParameter(std::string name, std::string value) ErrorStoreMode = StringToEnum(value); // Temperature Simulation related else if (name == "StaticTemperatureDefaultValue") - StaticTemperatureDefaultValue = string2int(value); + temperatureSim.StaticTemperatureDefaultValue = string2int(value); else if (name == "DynTemperatureSimPeriod") - DynTemperatureSimPeriod = string2int(value); + temperatureSim.DynTemperatureSimPeriod = string2int(value); else if (name == "DynTemperatureSimUnit") - DynTemperatureSimUnit = string2TimeUnit(value); + temperatureSim.DynTemperatureSimUnit = string2TimeUnit(value); + else if (name == "PowerThresholdsFile") { + temperatureSim.powerThresholdsFile = value; + temperatureSim.parsePowerThresholdsFile(); + } else { SC_REPORT_FATAL("Configuration", ("Parameter " + name + " not defined in Configuration").c_str()); @@ -174,4 +178,3 @@ void Configuration::setParameters(std::map parameterMa } } - diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index 562b05e7..ab5b71fd 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -41,6 +41,7 @@ #include #include #include "MemSpec.h" +#include "temperatureSimConfig.h" #include "../../../common/Utils.h" enum class ErrorStorageMode; @@ -92,9 +93,7 @@ struct Configuration ErrorStorageMode ErrorStoreMode; // Temperature Simulation related - int StaticTemperatureDefaultValue; - unsigned int DynTemperatureSimPeriod; - enum sc_time_unit DynTemperatureSimUnit; + TemperatureSimConfig temperatureSim; private: Configuration(); diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h new file mode 100644 index 00000000..4d407569 --- /dev/null +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2015, University of Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: + * Eder F. Zulian + */ + +#ifndef TEMPERATURE_SIM_CONFIG_H_ +#define TEMPERATURE_SIM_CONFIG_H_ + +#include +#include +#include + +#include "../../../common/DebugManager.h" +#include "../../../common/third_party/tinyxml2/tinyxml2.h" +#include "../../../common/Utils.h" + +struct TemperatureSimConfig { + + // Static Temperature Simulation parameters + int StaticTemperatureDefaultValue; + + // Dynamic Temeperature Simulation parameters + unsigned int DynTemperatureSimPeriod; + enum sc_time_unit DynTemperatureSimUnit; + + std::string powerThresholdsFile; + std::map cpuPowerThresholds; + std::map gpuPowerThresholds; + std::map dramPowerThresholds; + + void parsePowerThresholdsFile() + { + printDebugMessage("Power Thresholds File is " + powerThresholdsFile); + + // Load the XML file into memory and parse it + tinyxml2::XMLDocument xml; + loadXML(powerThresholdsFile, xml); + tinyxml2::XMLElement *powerThresholds = xml.FirstChildElement("power_thresholds"); + + if (powerThresholds == NULL) { + // Invalid file + std::string errormsg = "Invalid Power Thresholds File " + powerThresholdsFile; + printDebugMessage(errormsg); + SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str()); + throw; + } + + for (tinyxml2::XMLElement *e = powerThresholds->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { + + std::string id_str = e->Attribute("id"); + std::string thr_str = e->Attribute("value"); + + int id = std::stoi(id_str); + float thr = std::stof(thr_str); + + std::string name = e->Name(); + if (name == "cpu") { + cpuPowerThresholds.insert(std::map::value_type(id, thr)); + } else if (name == "gpu") { + gpuPowerThresholds.insert(std::map::value_type(id, thr)); + } else if (name == "dram") { + dramPowerThresholds.insert(std::map::value_type(id, thr)); + } else { + printDebugMessage("Unknown element ignored: " + name); + } + } + } + + void printDebugMessage(std::string message) + { + DebugManager::getInstance().printDebugMessage("Temperature Sim Config", message); + } +}; + +#endif /* TEMPERATURE_SIM_CONFIG_H_ */ + diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 30891f00..232554f6 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -105,7 +105,7 @@ errorModel::errorModel() std::stringstream msg; if (dynamicTemepratureSimulation == false) { - int temperature = Configuration::getInstance().StaticTemperatureDefaultValue; + int temperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; setTemperature(temperature); msg << "Static temperature simulation. Temperature set to " << temperature << std::endl; } else { diff --git a/DRAMSys/tests/error/sim-batch.xml b/DRAMSys/tests/error/sim-batch.xml index a7ab19c0..2d0940cb 100644 --- a/DRAMSys/tests/error/sim-batch.xml +++ b/DRAMSys/tests/error/sim-batch.xml @@ -1,12 +1,22 @@ + + + + + + + + + + From 4c82592d0ab2cf432ec3662e65277fa18d9b8d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 30 Sep 2015 10:12:34 +0200 Subject: [PATCH 06/39] Function to show the thresoulds config. Readme updated. --- .../core/configuration/temperatureSimConfig.h | 14 +++++++++++++- README.md | 3 +++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h index 4d407569..47801967 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -94,8 +94,20 @@ struct TemperatureSimConfig { printDebugMessage("Unknown element ignored: " + name); } } + + showTemperatureSimConfig(); } - + + void showTemperatureSimConfig() + { + for (auto e : cpuPowerThresholds) + printDebugMessage("CPU[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + for (auto e : gpuPowerThresholds) + printDebugMessage("GPU[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + for (auto e : dramPowerThresholds) + printDebugMessage("DRAM[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + } + void printDebugMessage(std::string message) { DebugManager::getInstance().printDebugMessage("Temperature Sim Config", message); diff --git a/README.md b/README.md index 2ba6dbb1..44fc6227 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ The XML code below shows a typic configuration: + @@ -255,6 +256,8 @@ 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 - **Memory Specification** From f6e59d5c0433cfd05e1e23a40c031c655b2b6fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 30 Sep 2015 17:42:56 +0200 Subject: [PATCH 07/39] Temperature Controller skeleton --- .../resources/simulations/sim-batch.xml | 6 +- DRAMSys/simulator/simulator.pro | 2 + .../core/configuration/Configuration.cpp | 4 + .../core/configuration/temperatureSimConfig.h | 11 +- DRAMSys/simulator/src/error/errormodel.cpp | 26 +--- DRAMSys/simulator/src/error/errormodel.h | 2 - .../simulator/src/simulation/Simulation.cpp | 7 +- .../src/simulation/TemperatureController.cpp | 115 ++++++++++++++++++ .../src/simulation/TemperatureController.h | 96 +++++++++++++++ 9 files changed, 237 insertions(+), 32 deletions(-) create mode 100644 DRAMSys/simulator/src/simulation/TemperatureController.cpp create mode 100644 DRAMSys/simulator/src/simulation/TemperatureController.h diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 1ab6a01e..d8ccba71 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -7,15 +7,17 @@ - + - + + + diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index 4109ea70..a3c59a0d 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -61,6 +61,7 @@ SOURCES += \ src/simulation/Simulation.cpp \ src/simulation/MemoryManager.cpp \ src/simulation/main.cpp \ + src/simulation/TemperatureController.cpp \ src/controller/scheduler/readwritegrouper.cpp \ src/controller/core/configuration/ConfigurationLoader.cpp \ src/controller/core/powerdown/NoPowerDown.cpp \ @@ -121,6 +122,7 @@ HEADERS += \ src/simulation/StlDataPlayer.h \ src/simulation/TracePlayerListener.h \ src/simulation/TraceGenerator.h \ + src/simulation/TemperatureController.h \ src/controller/core/powerdown/NoPowerDown.h \ src/controller/Command.h \ src/controller/RowBufferStates.h \ diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index b8671bbb..bc6107c2 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -163,6 +163,10 @@ void Configuration::setParameter(std::string name, std::string value) temperatureSim.powerThresholdsFile = value; temperatureSim.parsePowerThresholdsFile(); } + else if (name == "IceServerIp") + temperatureSim.IceServerIp = value; + else if (name == "IceServerPort") + temperatureSim.IceServerPort = string2int(value); 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 47801967..77bf3090 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -31,6 +31,7 @@ * * Authors: * Eder F. Zulian + * Matthias Jung */ #ifndef TEMPERATURE_SIM_CONFIG_H_ @@ -52,6 +53,8 @@ struct TemperatureSimConfig { // Dynamic Temeperature Simulation parameters unsigned int DynTemperatureSimPeriod; enum sc_time_unit DynTemperatureSimUnit; + std::string IceServerIp; + unsigned int IceServerPort; std::string powerThresholdsFile; std::map cpuPowerThresholds; @@ -60,7 +63,7 @@ struct TemperatureSimConfig { void parsePowerThresholdsFile() { - printDebugMessage("Power Thresholds File is " + powerThresholdsFile); + printDebugMessage("Power Thresholds File: " + powerThresholdsFile); // Load the XML file into memory and parse it tinyxml2::XMLDocument xml; @@ -101,11 +104,11 @@ struct TemperatureSimConfig { void showTemperatureSimConfig() { for (auto e : cpuPowerThresholds) - printDebugMessage("CPU[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + printDebugMessage("CPU[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); for (auto e : gpuPowerThresholds) - printDebugMessage("GPU[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + printDebugMessage("GPU[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); for (auto e : dramPowerThresholds) - printDebugMessage("DRAM[" + std::to_string(e.first) + "] threshold is " + std::to_string(e.second)); + printDebugMessage("DRAM[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); } void printDebugMessage(std::string message) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 232554f6..9a9182f0 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -35,14 +35,16 @@ #include "errormodel.h" #include "../common/DebugManager.h" +#include "../simulation/TemperatureController.h" + #include #include #include + errorModel::errorModel() { // Get Configuration parameters: - dynamicTemepratureSimulation = Configuration::getInstance().DynamicTemperatureSimulation; busWidth = Configuration::getInstance().Buswidth; burstLenght = Configuration::getInstance().memSpec.BurstLength; numberOfColumns = Configuration::getInstance().memSpec.NumberOfColumns; @@ -103,16 +105,6 @@ errorModel::errorModel() //weakCells[0].row = 0; //weakCells[0].dependent = true; - std::stringstream msg; - if (dynamicTemepratureSimulation == false) { - int temperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; - setTemperature(temperature); - msg << "Static temperature simulation. Temperature set to " << temperature << std::endl; - } else { - msg << "Dynamic temperature simulation." << std::endl; - } - DebugManager::getInstance().printDebugMessage(name, msg.str()); - markBitFlips(); } @@ -501,19 +493,9 @@ unsigned int errorModel::getBit(int row, int column, int byteInColumn, int bitIn return getBit(key, byteInColumn, bitInByte); } -void errorModel::setTemperature(double t) -{ - temperature = t; -} - double errorModel::getTemperature() { - if (dynamicTemepratureSimulation == true) { - // TODO Get temperature from 3d-ice simulator or other temperature source - // TODO Check all the criterion before requesting the temperature - return temperature; - } - + double temperature = TemperatureController::getInstance().getTemperature(); return temperature; } diff --git a/DRAMSys/simulator/src/error/errormodel.h b/DRAMSys/simulator/src/error/errormodel.h index aac91278..a7950e55 100644 --- a/DRAMSys/simulator/src/error/errormodel.h +++ b/DRAMSys/simulator/src/error/errormodel.h @@ -61,13 +61,11 @@ class errorModel unsigned int numberOfColumns; unsigned int bytesPerColumn; unsigned int numberOfRows; - bool dynamicTemepratureSimulation; // Name: std::string name; // Online Parameters: - double temperature; unsigned int numberOfBitErrorEvents; // Private Methods: diff --git a/DRAMSys/simulator/src/simulation/Simulation.cpp b/DRAMSys/simulator/src/simulation/Simulation.cpp index 932a3912..9b84334b 100644 --- a/DRAMSys/simulator/src/simulation/Simulation.cpp +++ b/DRAMSys/simulator/src/simulation/Simulation.cpp @@ -48,6 +48,7 @@ #include "../controller/core/configuration/ConfigurationLoader.h" #include "../common/Utils.h" #include "../simulation/StlDataPlayer.h" +#include "../simulation/TemperatureController.h" using namespace std; @@ -69,7 +70,6 @@ Simulation::Simulation(sc_module_name __attribute__((unused)) name, string pathT setupDebugManager(traceName); } - void Simulation::setupDebugManager(const string& traceName) { auto& dbg = DebugManager::getInstance(); @@ -79,7 +79,6 @@ void Simulation::setupDebugManager(const string& traceName) dbg.openDebugFile(traceName + ".txt"); } - void Simulation::setupTlmRecorders(const string &traceName, const string &pathToResources, const std::vector &devices) { // Create TLM Recorders, one per channel. @@ -106,6 +105,10 @@ void Simulation::setupTlmRecorders(const string &traceName, const string &pathTo void Simulation::instantiateModules(const string &traceName, const string &pathToResources, const std::vector &devices) { + // The first call to getInstance() creates the Temperature Controller. + // The same instance will can be accessed by all other modules. + TemperatureController::getInstance(); + for (size_t i = 0; i < Configuration::getInstance().NumberOfTracePlayers; i++) { std::string playerStr = "player" + std::to_string(i); TracePlayer<> *player; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp new file mode 100644 index 00000000..b9a95255 --- /dev/null +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2015, University of Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: + * Eder F. Zulian + * Matthias Jung + */ + +#include "TemperatureController.h" +#include "../controller/core/configuration/Configuration.h" + +void TemperatureController::setTemperature(double t) +{ + // XXX + // mutex for dynamic temperature simulation + temperature = t; +} + +double TemperatureController::getTemperature() +{ + printDebugMessage("Temperature is " + std::to_string(temperature)); + return temperature; +} + +void TemperatureController::temperatureThread() +{ + unsigned int period = Configuration::getInstance().temperatureSim.DynTemperatureSimPeriod; + enum sc_time_unit t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; + + std::vector powerValues = { + 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 + }; + + while (true) { + std::vector temperatureValues; + + thermalSimulation->sendPowerValues(&powerValues); + + thermalSimulation->simulate(); + + thermalSimulation->getTemperature(temperatureValues, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TCELL, TDICE_OUTPUT_QUANTITY_NONE); + + for (auto t : temperatureValues) + printDebugMessage("Temperature is " + std::to_string(t)); + + // TODO + // store temperatures + // evaluate thresholds + // take a look in all the available getTemperature() options + + wait(sc_time(period, t_unit)); + } +} + +void TemperatureController::printDebugMessage(std::string message) +{ + DebugManager::getInstance().printDebugMessage(name(), message); +} + diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h new file mode 100644 index 00000000..1f090260 --- /dev/null +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2015, University of Kaiserslautern + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: + * Eder F. Zulian + * Matthias Jung + */ + +#ifndef TEMPERATURE_CONTROLLER_H_ +#define TEMPERATURE_CONTROLLER_H_ + +#include +#include +#include + +#include "../common/DebugManager.h" +#include "../common/Utils.h" +#include "../controller/core/configuration/Configuration.h" +#include "IceWrapper.h" + +SC_MODULE(TemperatureController) { +public: + static inline TemperatureController &getInstance() + { + static TemperatureController temperaturectrl("TemperatureController"); + return temperaturectrl; + } + + SC_CTOR(TemperatureController) + { + dynamicTempSimEnabled = Configuration::getInstance().DynamicTemperatureSimulation; + + if (dynamicTempSimEnabled == true) { + + std::string ip = Configuration::getInstance().temperatureSim.IceServerIp; + unsigned int port = Configuration::getInstance().temperatureSim.IceServerPort; + + printDebugMessage("Dynamic temperature simulation. Server @ " + ip + ":" + std::to_string(port)); + + thermalSimulation = new IceWrapper(ip, port); + SC_THREAD(temperatureThread); + + } else { + double temperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; + setTemperature(temperature); + printDebugMessage("Static temperature simulation. Temperature set to " + std::to_string(temperature)); + } + } + + // TODO + // Implement many signatures for getTemperature(): + // - by (x,y,z) coordinates + // - device average temperature + double getTemperature(); + +private: + IceWrapper *thermalSimulation; + double temperature; + bool dynamicTempSimEnabled; + + void setTemperature(double t); + void temperatureThread(); + + void printDebugMessage(std::string message); +}; + +#endif /* TEMPERATURE_CONTROLLER_H_ */ + From 43b576dffa7ff1e5e202eb3e8d624af94154d1b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 30 Sep 2015 17:47:24 +0200 Subject: [PATCH 08/39] Readme updated --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 44fc6227..a033ed7e 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,8 @@ The XML code below shows a typic configuration: + + @@ -258,6 +260,10 @@ Below are listed the configuration sections and configuration fields. - "fs": femtoseconds - *PowerThresholdsFile* (string) - File containing the power thresholds that trigger the temperature simulation + - *IceServerIp* (string) + - 3D-Ice server IP address + - *IceServerPort* (unsigned int) + - 3D-Ice server port - **Memory Specification** From 63eae4d1ee3053d5ef61dc69f802d48783b738e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Fri, 2 Oct 2015 17:33:10 +0200 Subject: [PATCH 09/39] Thermal simulation period adjustment mechanism implemented. --- .../temperature_sim/power_thresholds.xml | 35 ++++- .../core/configuration/Configuration.cpp | 2 +- .../core/configuration/temperatureSimConfig.h | 38 ++--- DRAMSys/simulator/src/error/errormodel.cpp | 2 +- .../src/simulation/TemperatureController.cpp | 141 +++++++++++------- .../src/simulation/TemperatureController.h | 79 ++++++++-- README.md | 2 +- 7 files changed, 193 insertions(+), 106 deletions(-) diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml b/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml index c3ade839..e8e086ab 100644 --- a/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml +++ b/DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml @@ -1,8 +1,33 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index bc6107c2..b26f1fa0 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -156,7 +156,7 @@ void Configuration::setParameter(std::string name, std::string value) else if (name == "StaticTemperatureDefaultValue") temperatureSim.StaticTemperatureDefaultValue = string2int(value); else if (name == "DynTemperatureSimPeriod") - temperatureSim.DynTemperatureSimPeriod = string2int(value); + temperatureSim.DynTemperatureSimPeriod = std::stod(value.c_str()); else if (name == "DynTemperatureSimUnit") temperatureSim.DynTemperatureSimUnit = string2TimeUnit(value); else if (name == "PowerThresholdsFile") { diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h index 77bf3090..84e12d00 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -51,15 +51,13 @@ struct TemperatureSimConfig { int StaticTemperatureDefaultValue; // Dynamic Temeperature Simulation parameters - unsigned int DynTemperatureSimPeriod; + double DynTemperatureSimPeriod; enum sc_time_unit DynTemperatureSimUnit; std::string IceServerIp; unsigned int IceServerPort; std::string powerThresholdsFile; - std::map cpuPowerThresholds; - std::map gpuPowerThresholds; - std::map dramPowerThresholds; + std::vector powerThresholds; void parsePowerThresholdsFile() { @@ -68,9 +66,9 @@ struct TemperatureSimConfig { // Load the XML file into memory and parse it tinyxml2::XMLDocument xml; loadXML(powerThresholdsFile, xml); - tinyxml2::XMLElement *powerThresholds = xml.FirstChildElement("power_thresholds"); + tinyxml2::XMLElement *powThrElem = xml.FirstChildElement("power_thresholds"); - if (powerThresholds == NULL) { + if (powThrElem == NULL) { // Invalid file std::string errormsg = "Invalid Power Thresholds File " + powerThresholdsFile; printDebugMessage(errormsg); @@ -78,24 +76,10 @@ struct TemperatureSimConfig { throw; } - for (tinyxml2::XMLElement *e = powerThresholds->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { - - std::string id_str = e->Attribute("id"); + for (tinyxml2::XMLElement *e = powThrElem->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { std::string thr_str = e->Attribute("value"); - - int id = std::stoi(id_str); float thr = std::stof(thr_str); - - std::string name = e->Name(); - if (name == "cpu") { - cpuPowerThresholds.insert(std::map::value_type(id, thr)); - } else if (name == "gpu") { - gpuPowerThresholds.insert(std::map::value_type(id, thr)); - } else if (name == "dram") { - dramPowerThresholds.insert(std::map::value_type(id, thr)); - } else { - printDebugMessage("Unknown element ignored: " + name); - } + powerThresholds.push_back(thr); } showTemperatureSimConfig(); @@ -103,12 +87,10 @@ struct TemperatureSimConfig { void showTemperatureSimConfig() { - for (auto e : cpuPowerThresholds) - printDebugMessage("CPU[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); - for (auto e : gpuPowerThresholds) - printDebugMessage("GPU[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); - for (auto e : dramPowerThresholds) - printDebugMessage("DRAM[" + std::to_string(e.first) + "] threshold: " + std::to_string(e.second)); + int i = 0; + for (auto e : powerThresholds) { + printDebugMessage("powerThreshold[" + std::to_string(i++) + "]: " + std::to_string(e)); + } } void printDebugMessage(std::string message) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 9a9182f0..ac859a93 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -495,7 +495,7 @@ unsigned int errorModel::getBit(int row, int column, int byteInColumn, int bitIn double errorModel::getTemperature() { - double temperature = TemperatureController::getInstance().getTemperature(); + 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 b9a95255..de2b6dab 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -34,77 +34,104 @@ * Matthias Jung */ +#include + #include "TemperatureController.h" #include "../controller/core/configuration/Configuration.h" -void TemperatureController::setTemperature(double t) +double TemperatureController::getTemperature(int deviceId, float currentPower) { - // XXX - // mutex for dynamic temperature simulation - temperature = t; + if (dynamicTempSimEnabled == true) { + // XXX do I need a mutex here? + currentPowerValues.at(deviceId) = currentPower; + return temperatureValues.at(deviceId); + } else { + printDebugMessage("Temperature is " + std::to_string(staticTemperature)); + return staticTemperature; + } } -double TemperatureController::getTemperature() +void TemperatureController::updateTemperatures() { - printDebugMessage("Temperature is " + std::to_string(temperature)); - return temperature; + thermalSimulation->sendPowerValues(¤tPowerValues); + thermalSimulation->simulate(); + thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TCELL, TDICE_OUTPUT_QUANTITY_NONE); + // save values just obtained for posterior use + temperatureValues = temperaturesBuffer; + // clear the buffer, otherwise it will grow every request + temperaturesBuffer.clear(); +} + +double TemperatureController::adjustThermalSimPeriod() +{ + // Temperature Simulation Period Dynamic Adjustment + // + // 1. Adjustment is requierd when: + // + // 1.1. The power dissipation of one or more devices change considerably + // (reaches the configured threshold for that device in any direction, + // i.e. increases or decreases substantially) during the current + // simulaiton period. + // + // 1.1.1. The simulation period will be reduced by a factor of 'n' so the + // simulation occurs 'n' times more often. + // + // 1.1.2. The step 1.1.1 will be repeated until the point that there are + // no sustantial changes in power dissipation between two consecutive + // executions of the thermal simulation, i.e. all changes for all devices + // are less than the configured threshold. + // + // 1.2. The current simulation period differs from the target period + // 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 + // steps of 'n/2' until it achieves the desired value given by + // configuration or the described in 1.1 occurs. + + bool decreaseSimPeriod = false; + + for (unsigned i = 0; i < currentPowerValues.size(); i++) { + if (std::abs(lastPowerValues.at(i) - currentPowerValues.at(i)) > powerThresholds.at(i)) { + cyclesSinceLastPeriodAdjust = 0; + decreaseSimPeriod = true; + } + } + + lastPowerValues = currentPowerValues; + + if (decreaseSimPeriod == true) { + period = period / periodAdjustFactor; + printDebugMessage("Thermal Simulation period reduced to " + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); + } else { + if (period != targetPeriod) { + cyclesSinceLastPeriodAdjust++; + if (cyclesSinceLastPeriodAdjust >= nPowStableCyclesToIncreasePeriod) { + cyclesSinceLastPeriodAdjust = 0; + period = period * (periodAdjustFactor / 2); + printDebugMessage("Thermal Simulation period increased to " + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); + if (period > targetPeriod) + period = targetPeriod; + } + } + } + + return period; } void TemperatureController::temperatureThread() { - unsigned int period = Configuration::getInstance().temperatureSim.DynTemperatureSimPeriod; - enum sc_time_unit t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; - - std::vector powerValues = { - 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 - }; - while (true) { - std::vector temperatureValues; + updateTemperatures(); + double p = adjustThermalSimPeriod(); - thermalSimulation->sendPowerValues(&powerValues); + int i = 0; + for (auto t : temperatureValues) { + printDebugMessage("Temperature[" + std::to_string(i++) + "] is " + std::to_string(t)); + } + printDebugMessage("Thermal simulation period is " + std::to_string(p)); - thermalSimulation->simulate(); - - thermalSimulation->getTemperature(temperatureValues, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TCELL, TDICE_OUTPUT_QUANTITY_NONE); - - for (auto t : temperatureValues) - printDebugMessage("Temperature is " + std::to_string(t)); - - // TODO - // store temperatures - // evaluate thresholds - // take a look in all the available getTemperature() options - - wait(sc_time(period, t_unit)); + wait(sc_time(p, t_unit)); } } diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 1f090260..4b9ee481 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -62,32 +62,85 @@ public: 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)); - thermalSimulation = new IceWrapper(ip, 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 + }; + + lastPowerValues = currentPowerValues; + + powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds; + periodAdjustFactor = 10; + nPowStableCyclesToIncreasePeriod = 5; + cyclesSinceLastPeriodAdjust = 0; + + targetPeriod = Configuration::getInstance().temperatureSim.DynTemperatureSimPeriod; + period = targetPeriod; + t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; SC_THREAD(temperatureThread); } else { - double temperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; - setTemperature(temperature); - printDebugMessage("Static temperature simulation. Temperature set to " + std::to_string(temperature)); + staticTemperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; + printDebugMessage("Static temperature simulation. Temperature set to " + std::to_string(staticTemperature)); } } - // TODO - // Implement many signatures for getTemperature(): - // - by (x,y,z) coordinates - // - device average temperature - double getTemperature(); - + double getTemperature(int deviceId, float currentPower); + private: - IceWrapper *thermalSimulation; - double temperature; + double staticTemperature; + bool dynamicTempSimEnabled; - void setTemperature(double t); + IceWrapper *thermalSimulation; + std::vector temperaturesBuffer; + std::vector temperatureValues; + + std::vector currentPowerValues; + std::vector lastPowerValues; + std::vector powerThresholds; + + double targetPeriod; + double period; + enum sc_time_unit t_unit; void temperatureThread(); + void updateTemperatures(); + double adjustThermalSimPeriod(); + unsigned int periodAdjustFactor; + unsigned int cyclesSinceLastPeriodAdjust; + unsigned int nPowStableCyclesToIncreasePeriod; void printDebugMessage(std::string message); }; diff --git a/README.md b/README.md index a033ed7e..47c750d7 100644 --- a/README.md +++ b/README.md @@ -249,7 +249,7 @@ Below are listed the configuration sections and configuration fields. - **Temperature Simulator Configuration** - *StaticTemperatureDefaultValue* (int) - Temperature value for simulations with static temperature - - *DynTemperatureSimPeriod* (unsigned int) + - *DynTemperatureSimPeriod* (double) - Period of the dynamic temperature simulation - *DynTemperatureSimUnit* (string) - "s": seconds From 995a18e6483877c3a8df3ae56f223741c314462d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Sat, 3 Oct 2015 19:56:20 +0200 Subject: [PATCH 10/39] Improvements --- .../configs/temperature_sim/powerInfo.xml | 32 ++++++++++++++ .../temperature_sim/power_thresholds.xml | 33 -------------- .../resources/simulations/sim-batch.xml | 4 +- .../core/configuration/Configuration.cpp | 10 +++-- .../core/configuration/temperatureSimConfig.h | 31 +++++++++---- DRAMSys/simulator/src/error/errormodel.cpp | 3 ++ .../src/simulation/TemperatureController.cpp | 5 ++- .../src/simulation/TemperatureController.h | 43 +++---------------- README.md | 12 ++++-- 9 files changed, 86 insertions(+), 87 deletions(-) create mode 100644 DRAMSys/simulator/resources/configs/temperature_sim/powerInfo.xml delete mode 100644 DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml 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** From 53252439d5864d2cce1c5c63ae1b1d761bc06b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 5 Oct 2015 13:52:03 +0200 Subject: [PATCH 11/39] Comments improved --- .../src/controller/core/configuration/temperatureSimConfig.h | 2 ++ README.md | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h index 4cc9949c..efb128d0 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -82,10 +82,12 @@ struct TemperatureSimConfig { for (tinyxml2::XMLElement *e = powInfoElem->FirstChildElement(); e != NULL; e = e->NextSiblingElement()) { + // Load initial power values for all devices std::string init_pow_str = e->Attribute("init_pow"); float pow = std::stof(init_pow_str); powerInitialValues.push_back(pow); + // Load power thresholds for all devices (changes in power dissipation that exceed the threshods will make the thermal simulation to be executed more often) std::string thr_str = e->Attribute("threshold"); float thr = std::stof(thr_str); powerThresholds.push_back(thr); diff --git a/README.md b/README.md index 85932202..b0b853bb 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ Below are listed the configuration sections and configuration fields. - *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. + - Wait this number of thermal simulation 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** From ba290a544709ca2d3e0a9bedc339b13f5e7adef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 5 Oct 2015 14:54:43 +0200 Subject: [PATCH 12/39] Temperature scale is now configurable --- .../resources/simulations/sim-batch.xml | 1 + .../core/configuration/Configuration.cpp | 7 +++++++ .../core/configuration/temperatureSimConfig.h | 3 +++ .../src/simulation/TemperatureController.cpp | 20 +++++++++++++++++-- .../src/simulation/TemperatureController.h | 5 +++++ README.md | 5 +++++ 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index cdc39f5e..f3db2d42 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -12,6 +12,7 @@ + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 8e2b155b..313f0f51 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -153,6 +153,13 @@ void Configuration::setParameter(std::string name, std::string value) else if(name == "ErrorStoreMode") ErrorStoreMode = StringToEnum(value); // Temperature Simulation related + else if (name == "TemperatureScale") { + if (value != "Celsius" && value != "Fahrenheit" && value != "Kelvin") { + SC_REPORT_FATAL("Configuration", ("Invalid value for parameter " + name + ".").c_str()); + throw; + } + temperatureSim.TemperatureScale = value; + } else if (name == "StaticTemperatureDefaultValue") temperatureSim.StaticTemperatureDefaultValue = string2int(value); else if (name == "DynTemperatureSimPeriod") diff --git a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h index efb128d0..141aea78 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -47,6 +47,9 @@ struct TemperatureSimConfig { + // Temperature Scale + std::string TemperatureScale; + // Static Temperature Simulation parameters int StaticTemperatureDefaultValue; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index a740deba..2eb3bbe0 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -39,13 +39,29 @@ #include "TemperatureController.h" #include "../controller/core/configuration/Configuration.h" +double TemperatureController::temperatureConvert(double tKelvin) +{ + if (temperatureScale == "Celsius") { + return tKelvin - 273.15; + } + else if (temperatureScale == "Fahrenheit") { + return (tKelvin - 273.15) * 1.8 + 32; + } + + return tKelvin; +} + double TemperatureController::getTemperature(int deviceId, float currentPower) { if (dynamicTempSimEnabled == true) { currentPowerValues.at(deviceId) = currentPower; + + // FIXME using the static temperature value until the vector of + // temperatures is filled if (temperatureValues.empty()) - return staticTemperature; - return temperatureValues.at(deviceId); + return temperatureConvert(staticTemperature + 273.15); + + return temperatureConvert(temperatureValues.at(deviceId)); } else { printDebugMessage("Temperature is " + std::to_string(staticTemperature)); return staticTemperature; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 19ef7674..372f2ac8 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -56,6 +56,8 @@ public: SC_CTOR(TemperatureController) { + temperatureScale = Configuration::getInstance().temperatureSim.TemperatureScale; + dynamicTempSimEnabled = Configuration::getInstance().DynamicTemperatureSimulation; if (dynamicTempSimEnabled == true) { @@ -91,6 +93,9 @@ public: double getTemperature(int deviceId, float currentPower); private: + std::string temperatureScale; + double temperatureConvert(double tKelvin); + double staticTemperature; bool dynamicTempSimEnabled; diff --git a/README.md b/README.md index b0b853bb..e31780f1 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ The XML code below shows a typic configuration: + @@ -249,6 +250,10 @@ Below are listed the configuration sections and configuration fields. - "0": static temperature during simulation - **Temperature Simulator Configuration** + - *TemperatureScale* (string) + - "Celsius" + - "Fahrenheit" + - "Kelvin" - *StaticTemperatureDefaultValue* (int) - Temperature value for simulations with static temperature - *DynTemperatureSimPeriod* (double) From 687f077c8f43d8628d9e0ed78eb393e014400a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 5 Oct 2015 15:48:16 +0200 Subject: [PATCH 13/39] Default config is static temperature simulation --- DRAMSys/simulator/resources/simulations/sim-batch.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index f3db2d42..02cc12fb 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -7,7 +7,7 @@ - + From 8050bad57f2f6e2984e04aa4ebb4cbcf1e19689d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 7 Oct 2015 15:59:38 +0200 Subject: [PATCH 14/39] Thermal simulation can be enabled via environment variable. mkdir build cd build export THERMALSIM=true qmake ../DRAMSys/dram.vp.system.pro make [-j16] Pending: - README file update --- DRAMSys/dram.vp.system.pro | 15 ++++++++-- DRAMSys/simulator/simulator.pro | 29 ++++++++++++++----- .../src/simulation/TemperatureController.cpp | 20 +++++++------ .../src/simulation/TemperatureController.h | 12 ++++++-- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/DRAMSys/dram.vp.system.pro b/DRAMSys/dram.vp.system.pro index d1a3d29f..37b7397b 100644 --- a/DRAMSys/dram.vp.system.pro +++ b/DRAMSys/dram.vp.system.pro @@ -1,8 +1,17 @@ TEMPLATE = subdirs -SUBDIRS = simulator/src/common/third_party/icewrapper/3D-ICE-SystemC-Client.pro +thermalsim = $$(THERMALSIM) +$$eval(thermalsim) { + message(Thermal Simulation Feature Enabled) + + # build the project sequentially as listed in SUBDIRS + CONFIG += ordered + + SUBDIRS += simulator/src/common/third_party/icewrapper/3D-ICE-SystemC-Client.pro +} else { + message(Thermal Simulation Feature Disabled) +} + SUBDIRS += simulator/simulator.pro SUBDIRS += analyzer/traceAnalyzer.pro -# build the project sequentially as listed in SUBDIRS -CONFIG += ordered diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index a3c59a0d..9f18dd15 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -134,15 +134,28 @@ HEADERS += \ src/controller/core/configuration/ConfigurationLoader.h \ src/error/errormodel.h +thermalsim = $$(THERMALSIM) +$$eval(thermalsim) { + message(Thermal Simulation Feature Enabled) -LIBS += -L/opt/3D-ICE/lib -lthreed-ice-2.2.5 -LIBS += -L/opt/SuperLU_4.3/lib -lsuperlu_4.3 -LIBS += -lblas + LIBS += -L/opt/3D-ICE/lib -lthreed-ice-2.2.5 + LIBS += -L/opt/SuperLU_4.3/lib -lsuperlu_4.3 + LIBS += -lblas + message(Libraries: $${LIBS}) -INCLUDEPATH += /opt/3D-ICE/include -INCLUDEPATH += /opt/SuperLU_4.3/SRC -INCLUDEPATH += /opt/systemc/include -INCLUDEPATH += src/common/third_party/icewrapper + INCLUDEPATH += /opt/3D-ICE/include + INCLUDEPATH += /opt/SuperLU_4.3/SRC + INCLUDEPATH += /opt/systemc/include + INCLUDEPATH += src/common/third_party/icewrapper + message(Include paths: $${INCLUDEPATH}) -OBJECTS += $$(PWD)/src/common/third_party/icewrapper/IceWrapper.o + OBJECTS += $$(PWD)/src/common/third_party/icewrapper/IceWrapper.o + message(Objects: $${OBJECTS}) + + QMAKE_CXXFLAGS += -DTHERMALSIM + message(Compiler flags: $${QMAKE_CXXFLAGS}) + +} else { + message(Thermal Simulation Feature Disabled) +} diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index 2eb3bbe0..370c4195 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -43,8 +43,7 @@ double TemperatureController::temperatureConvert(double tKelvin) { if (temperatureScale == "Celsius") { return tKelvin - 273.15; - } - else if (temperatureScale == "Fahrenheit") { + } else if (temperatureScale == "Fahrenheit") { return (tKelvin - 273.15) * 1.8 + 32; } @@ -70,12 +69,14 @@ double TemperatureController::getTemperature(int deviceId, float currentPower) void TemperatureController::updateTemperatures() { +#ifdef THERMALSIM thermalSimulation->sendPowerValues(¤tPowerValues); thermalSimulation->simulate(); thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TCELL, TDICE_OUTPUT_QUANTITY_NONE); - // save values just obtained for posterior use +#endif + // Save values just obtained for posterior use temperatureValues = temperaturesBuffer; - // clear the buffer, otherwise it will grow every request + // Clear the buffer, otherwise it will grow every request temperaturesBuffer.clear(); } @@ -86,7 +87,7 @@ double TemperatureController::adjustThermalSimPeriod() // 1. Adjustment is requierd when: // // 1.1. The power dissipation of one or more devices change considerably - // (reaches the configured threshold for that device in any direction, + // (exceeds the configured threshold for that device in any direction, // i.e. increases or decreases substantially) during the current // simulaiton period. // @@ -101,9 +102,10 @@ double TemperatureController::adjustThermalSimPeriod() // 1.2. The current simulation period differs from the target period // 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 - // steps of 'n/2' until it achieves the desired value given by + // 1.2.1 Provided a scenario in which power dissipation changes do not + // exceed the thresholds, the situation period will be kept for a number + // of simulation cycles 'nc' and after 'nc' 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. bool decreaseSimPeriod = false; @@ -126,9 +128,9 @@ double TemperatureController::adjustThermalSimPeriod() if (cyclesSinceLastPeriodAdjust >= nPowStableCyclesToIncreasePeriod) { cyclesSinceLastPeriodAdjust = 0; period = period * (periodAdjustFactor / 2); - printDebugMessage("Thermal Simulation period increased to " + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); if (period > targetPeriod) period = targetPeriod; + printDebugMessage("Thermal Simulation period increased to " + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); } } } diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 372f2ac8..10913ce7 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -44,7 +44,10 @@ #include "../common/DebugManager.h" #include "../common/Utils.h" #include "../controller/core/configuration/Configuration.h" + +#ifdef THERMALSIM #include "IceWrapper.h" +#endif SC_MODULE(TemperatureController) { public: @@ -61,13 +64,15 @@ public: dynamicTempSimEnabled = Configuration::getInstance().DynamicTemperatureSimulation; if (dynamicTempSimEnabled == true) { +#ifdef THERMALSIM // 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)); - +#else + SC_REPORT_FATAL(name(), "Temperature Simulation Disabled"); +#endif // Initial power dissipation values (got from config) currentPowerValues = Configuration::getInstance().temperatureSim.powerInitialValues; lastPowerValues = currentPowerValues; @@ -83,7 +88,6 @@ public: period = targetPeriod; t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; SC_THREAD(temperatureThread); - } else { staticTemperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; printDebugMessage("Static temperature simulation. Temperature set to " + std::to_string(staticTemperature)); @@ -100,7 +104,9 @@ private: bool dynamicTempSimEnabled; +#ifdef THERMALSIM IceWrapper *thermalSimulation; +#endif std::vector temperaturesBuffer; std::vector temperatureValues; From f22d75eee9dacf169e1a387789ca6ec013c385ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 7 Oct 2015 16:21:32 +0200 Subject: [PATCH 15/39] README file updated with information on how to enable the thermal simulation feature --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index e31780f1..ce9e8f37 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,25 @@ $ cd analyzer $ ./traceAnalyzer ``` +### DRAMSys Thermal Simulation + + This feature can be enabled via an environment variable. + +``` bash +$ export THERMALSIM=true +$ qtcreator & +``` + +or + +``` bash +$ mkdir build +$ cd build +$ export THERMALSIM=true +$ qmake ../DRAMSys/dram.vp.system.pro +$ make +``` + ### DRAMSys Configuration The **dramSys** executable supports one argument which is a XML file that From 757aacbe47ebf088e10a0a8b1907b0dca394d41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 8 Oct 2015 17:40:35 +0200 Subject: [PATCH 16/39] README updated. - Added information on 3D-ICE installation and running. - Added references to 3D-ICE papers as requested by 3D-ICE authors in the project's website. --- README.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ce9e8f37..f45c9bae 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ $ ./traceAnalyzer ### DRAMSys Thermal Simulation - This feature can be enabled via an environment variable. +This feature can be enabled via an environment variable. ``` bash $ export THERMALSIM=true @@ -132,6 +132,26 @@ $ qmake ../DRAMSys/dram.vp.system.pro $ make ``` +The thermal simulation is performed by a **3D-ICE** [8] server accessed +through the network. Therefore users interested in thermal simulation during +their DRAMSys simulations need to make sure they have a 3D-ICE server up and +running before starting. + +More information about how to obtain 3D-ICE and its installation can be +obtained in the official website http://esl.epfl.ch/3D-ICE. + +Provided the user fulfilled this installation requisite, before starting +DRAMSys it is necessary to run the 3D-ICE server passing to it two arguments: +a suitable configuration file and an Internet socket port number. + +``` bash +$ 3D-ICE-Server +``` + +The IP address and the port number related to the server shall be informed in +DRAMSys' configuration to subsequent use by DRAMSys to access the thermal +simulation server. + ### DRAMSys Configuration The **dramSys** executable supports one argument which is a XML file that @@ -448,4 +468,20 @@ C. Weis, M. Jung, P. Ehses, C. Santos, P. Vivet, S. Goossens, M. Koedam, N. Wehn [7] http://www.uni-kl.de/3d-dram/publications/ +[8] A Sridhar, A Vincenzi, D Atienza, T Brunschwiler, 3D-ICE: a compact +thermal model for early-stage design of liquid-cooled ICs, IEEE Transactions +on Computers (TC 2013, accepted for publication). + +[9] A Sridhar, A Vincenzi, M Ruggiero, T Brunschwiler, D Atienza, 3D-ICE: Fast +compact transient thermal modeling for 3D-ICs with inter-tier liquid cooling, +Proceedings of the 2010 International Conference on Computer-Aided Design +(ICCAD 2010), San Jose, CA, USA, November 7-11 2010. + +[10] A Sridhar, A Vincenzi, M Ruggiero, T Brunschwiler, D Atienza, Compact +transient thermal model for 3D ICs with liquid cooling via enhanced heat +transfer cavity geometries, Proceedings of the 16th International Workshop on +Thermal Investigations of ICs and Systems (THERMINIC'10), Barcelona, Spain, +6-8 October, 2010. + +[11] http://esl.epfl.ch/3D-ICE From c37c9b3544a11059badc2221b2ffdfc3334a8f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 8 Oct 2015 17:49:53 +0200 Subject: [PATCH 17/39] README updated. --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f45c9bae..329246f5 100644 --- a/README.md +++ b/README.md @@ -142,10 +142,15 @@ obtained in the official website http://esl.epfl.ch/3D-ICE. Provided the user fulfilled this installation requisite, before starting DRAMSys it is necessary to run the 3D-ICE server passing to it two arguments: -a suitable configuration file and an Internet socket port number. +a suitable configuration file and an Internet socket port number. And wait +until the server is ready to receive requests. ``` bash $ 3D-ICE-Server +Preparing stk data ... done ! +Preparing thermal data ... done ! +Creating socket ... done ! +Waiting for client ... done ! ``` The IP address and the port number related to the server shall be informed in From abacc48a6c677128ea8e6a119dee06c3460e789f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 12 Oct 2015 13:00:03 +0200 Subject: [PATCH 18/39] Readme updated --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 329246f5..ba71c454 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,15 @@ $ ./traceAnalyzer ### DRAMSys Thermal Simulation +Before starting make sure you have a **clean repository** without any previous +automatic generated Makefiles. One way to ensure this is by running the +command below inside your DRAMSys repository, but keep in mind that **all +untracked files will be lost**. + +``` bash +$ git clean -fdx +``` + This feature can be enabled via an environment variable. ``` bash From 3d7b7793fd7ddb1e9d97c1536cd2ad6feddd8f9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 13 Oct 2015 16:55:00 +0200 Subject: [PATCH 19/39] Simple usage example --- .../resources/configs/memconfigs/fr_fcfs.xml | 2 +- .../configs/temperature_sim/core.flp | 45 ++++++++ .../resources/configs/temperature_sim/mem.flp | 16 +++ .../configs/temperature_sim/powerInfo.xml | 34 +----- .../configs/temperature_sim/stack.stk | 46 ++++++++ .../resources/simulations/sim-batch.xml | 8 +- DRAMSys/simulator/src/error/errormodel.cpp | 11 +- .../src/simulation/TemperatureController.cpp | 4 +- .../src/simulation/TemperatureController.h | 2 +- README.md | 103 +++++++++++++++++- 10 files changed, 228 insertions(+), 43 deletions(-) create mode 100755 DRAMSys/simulator/resources/configs/temperature_sim/core.flp create mode 100755 DRAMSys/simulator/resources/configs/temperature_sim/mem.flp create mode 100755 DRAMSys/simulator/resources/configs/temperature_sim/stack.stk diff --git a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml index 7f8af9a8..d0f996f0 100644 --- a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml +++ b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml @@ -9,7 +9,7 @@ - + + + + + diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk b/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk new file mode 100755 index 00000000..338130b7 --- /dev/null +++ b/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk @@ -0,0 +1,46 @@ +material SILICON : + thermal conductivity 1.30e-4 ; + volumetric heat capacity 1.628e-12 ; + +material BEOL : + thermal conductivity 2.25e-6 ; + volumetric heat capacity 2.175e-12 ; + +material COPPER : + thermal conductivity 4.01e-04 ; + volumetric heat capacity 3.37e-12 ; + +heat sink : + sink height 1e03, area 100e06, material COPPER ; + spreader height 0.5e03, area 70e06, material SILICON ; + heat transfer coefficient 1.3e-09 ; + ambient temperature 318.15 ; + +layer PCB : + height 10 ; + material BEOL ; + +die DRAM : + layer 58.5 SILICON ; + source 2 SILICON ; + layer 1.5 BEOL ; + layer 58.5 SILICON ; + +dimensions : + chip length 6100, width 10600 ; + cell length 100, width 100 ; + +stack: + die DRAM_DIE DRAM floorplan "./mem.flp" ; + layer CONN_TO_PCB PCB ; + +solver: + transient step 0.01, slot 0.05 ; + initial temperature 300.0 ; + +output: + Tflpel(DRAM_DIE.channel0 , "temp_flp_element_ch0.txt" , average , slot ); + Tflpel(DRAM_DIE.channel1 , "temp_flp_element_ch1.txt" , average , slot ); + Tflpel(DRAM_DIE.channel2 , "temp_flp_element_ch2.txt" , average , slot ); + Tflpel(DRAM_DIE.channel3 , "temp_flp_element_ch3.txt" , average , slot ); + diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index 02cc12fb..e4612577 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -4,16 +4,16 @@ - + - + - + @@ -37,7 +37,7 @@ - chstone-adpcm_32.stl + ../../../tests/error/test_error.stl diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index d2dc0129..44ec40d6 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -498,7 +498,16 @@ 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); + + // FIXME + // make sure the context is set (myChannel has the proper value) before + // requesting the temperature. + double temperature = 89; + + if (this->myChannel != -1) { + temperature = TemperatureController::getInstance().getTemperature(this->myChannel, 0); + } + return temperature; } diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index 370c4195..e30fc3f5 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -52,6 +52,8 @@ double TemperatureController::temperatureConvert(double tKelvin) double TemperatureController::getTemperature(int deviceId, float currentPower) { + printDebugMessage("Temperature requested by device " + std::to_string(deviceId) + " current power is " + std::to_string(currentPower)); + if (dynamicTempSimEnabled == true) { currentPowerValues.at(deviceId) = currentPower; @@ -72,7 +74,7 @@ void TemperatureController::updateTemperatures() #ifdef THERMALSIM thermalSimulation->sendPowerValues(¤tPowerValues); thermalSimulation->simulate(); - thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TCELL, TDICE_OUTPUT_QUANTITY_NONE); + thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TFLPEL, TDICE_OUTPUT_QUANTITY_AVERAGE); #endif // Save values just obtained for posterior use temperatureValues = temperaturesBuffer; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 10913ce7..fe9b5335 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -71,7 +71,7 @@ public: thermalSimulation = new IceWrapper(ip, port); printDebugMessage("Dynamic temperature simulation. Server @ " + ip + ":" + std::to_string(port)); #else - SC_REPORT_FATAL(name(), "Temperature Simulation Disabled"); + SC_REPORT_FATAL(name(), "DRAMSys was build without support to dynamic temperature simulation. Check the README file for further details."); #endif // Initial power dissipation values (got from config) currentPowerValues = Configuration::getInstance().temperatureSim.powerInitialValues; diff --git a/README.md b/README.md index ba71c454..f61e192d 100644 --- a/README.md +++ b/README.md @@ -117,8 +117,8 @@ $ ./traceAnalyzer Before starting make sure you have a **clean repository** without any previous automatic generated Makefiles. One way to ensure this is by running the -command below inside your DRAMSys repository, but keep in mind that **all -untracked files will be lost**. +command below inside your DRAMSys repository, but keep in mind that +**untracked files and directories will be removed** from the repository. ``` bash $ git clean -fdx @@ -146,13 +146,13 @@ through the network. Therefore users interested in thermal simulation during their DRAMSys simulations need to make sure they have a 3D-ICE server up and running before starting. -More information about how to obtain 3D-ICE and its installation can be -obtained in the official website http://esl.epfl.ch/3D-ICE. +More information about how to obtain 3D-ICE and how to intall it can be found +in the official website http://esl.epfl.ch/3D-ICE. Provided the user fulfilled this installation requisite, before starting DRAMSys it is necessary to run the 3D-ICE server passing to it two arguments: -a suitable configuration file and an Internet socket port number. And wait -until the server is ready to receive requests. +a suitable configuration file and an Internet socket port number. And then +wait until the server is ready to receive requests. ``` bash $ 3D-ICE-Server @@ -166,6 +166,97 @@ The IP address and the port number related to the server shall be informed in DRAMSys' configuration to subsequent use by DRAMSys to access the thermal simulation server. +#### Usage Example + +The DRAMSys' main configuration file is presented below. + +``` xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ../../../tests/error/test_error.stl + + + + +``` + +Enable the error model in fr_fcfs.xml. + +``` xml + + + + + + + + + + + + + +``` + +Generate the input trace file for DRAMSys. + +``` bash +$ cd DRAMSys/tests/error/ +$ ./generateErrorTest.pl > test_error.stl +``` + +Start the 3D-ICE server providing the stack file and the port number. + +``` bash +$ cd DRAMSys/simulator/resources/configs/temperature_sim +$ 3D-ICE-Server stack.stk 11880 +``` + +In another terminal or terminal tab start DRAMSys. Here the program's output +is redirected to a file. + +``` bash +$ cd build/simulator/ +$ ./dramSys > output +``` + ### DRAMSys Configuration The **dramSys** executable supports one argument which is a XML file that From a978c967b10dd2477edef85f9bc625a481ba72e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 14 Oct 2015 19:50:40 +0200 Subject: [PATCH 20/39] Error memory is now a vector of objects. --- DRAMSys/simulator/src/simulation/Dram.h | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index 127613f2..49c5740e 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -43,6 +43,7 @@ #include #include #include +#include #include "../common/DebugManager.h" #include "../common/dramExtension.h" #include "../controller/core/TimingCalculation.h" @@ -69,7 +70,7 @@ struct Dram : sc_module // Error Model related: ErrorStorageMode ErrorStoreMode = Configuration::getInstance().ErrorStoreMode; - errorModel * ememory; + std::vector ememory; // Data Storage: map< unsigned long int, unsigned char[BUSWIDTH/2] > memory; @@ -169,7 +170,11 @@ struct Dram : sc_module // For each bank in a channel a error Model is created: if(ErrorStoreMode == ErrorStorageMode::ErrorModel) { - ememory = new errorModel[Configuration::getInstance().memSpec.NumberOfBanks]; + for (unsigned i = 0; i < Configuration::getInstance().memSpec.NumberOfBanks; i++) { + errorModel *em; + em = new errorModel(); + ememory.push_back(em); + } } } @@ -183,7 +188,9 @@ struct Dram : sc_module cout << name() << string("\tAverage Power: \t") + to_string(DRAMPower->getPower().average_power) << endl; } // Clean up: - delete [] ememory; + for (auto e : ememory) { + delete e; + } //std::cout << "Simulated Memory Size: " << memory.size() << endl; // TODO Aufrauemen } @@ -217,7 +224,7 @@ struct Dram : sc_module if (ErrorStoreMode == ErrorStorageMode::ErrorModel) { - ememory[bank].activate(row); + ememory[bank]->activate(row); } } else if (phase == BEGIN_WR) @@ -235,7 +242,7 @@ struct Dram : sc_module } else // == 2 Use Storage with Error Model { - ememory[bank].store(payload); + ememory[bank]->store(payload); } sendToController(payload, END_WR, delay + getExecutionTime(Command::Write, payload)); } @@ -257,7 +264,7 @@ struct Dram : sc_module } else if(ErrorStoreMode == ErrorStorageMode::ErrorModel)// use ErrorStorageMode with errormodel { - ememory[bank].load(payload); + ememory[bank]->load(payload); } sendToController(payload, END_RD, delay + getExecutionTime(Command::Read, payload)); @@ -277,7 +284,7 @@ struct Dram : sc_module } else // == 2 Use Storage with Error Model { - ememory[bank].store(payload); + ememory[bank]->store(payload); } sendToController(payload, END_WRA, delay + getExecutionTime(Command::WriteA, payload)); } @@ -299,7 +306,7 @@ struct Dram : sc_module } else if(ErrorStoreMode == ErrorStorageMode::ErrorModel)// use ErrorStorageMode with errormodel { - ememory[bank].load(payload); + ememory[bank]->load(payload); } sendToController(payload, END_RDA, delay + getExecutionTime(Command::ReadA, payload)); @@ -312,7 +319,7 @@ struct Dram : sc_module if (ErrorStoreMode == ErrorStorageMode::ErrorModel) { - ememory[bank].refresh(row); + ememory[bank]->refresh(row); } } @@ -401,7 +408,7 @@ struct Dram : sc_module } else { - ememory[bank].load(trans); + ememory[bank]->load(trans); } } else if ( cmd == tlm::TLM_WRITE_COMMAND ) @@ -412,7 +419,7 @@ struct Dram : sc_module } else { - ememory[bank].store(trans); + ememory[bank]->store(trans); } } return len; From 82c165fb5358bf7010118a46c310853cf48f9b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 15 Oct 2015 11:26:18 +0200 Subject: [PATCH 21/39] When power analisys is enabled the error model will get the power information from DRAMPower. --- DRAMSys/simulator/src/error/errormodel.cpp | 30 +++++++++++++++++----- DRAMSys/simulator/src/error/errormodel.h | 5 ++++ DRAMSys/simulator/src/simulation/Dram.h | 6 ++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 44ec40d6..736d30d6 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -41,9 +41,9 @@ #include #include - -errorModel::errorModel() +void errorModel::init() { + powerAnalysis = Configuration::getInstance().PowerAnalysis; // Get Configuration parameters: busWidth = Configuration::getInstance().Buswidth; burstLenght = Configuration::getInstance().memSpec.BurstLength; @@ -108,6 +108,17 @@ errorModel::errorModel() markBitFlips(); } +errorModel::errorModel(libDRAMPower *dp) +{ + this->DRAMPower = dp; + init(); +} + +errorModel::errorModel() +{ + init(); +} + errorModel::~errorModel() { // Remove all data from the dataMap: @@ -495,17 +506,22 @@ 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. - // FIXME // make sure the context is set (myChannel has the proper value) before // requesting the temperature. double temperature = 89; if (this->myChannel != -1) { - temperature = TemperatureController::getInstance().getTemperature(this->myChannel, 0); + if (powerAnalysis == true) { + // TODO + // check if this is best way to request information to DRAMPower. + DRAMPower->updateCounters(true); + DRAMPower->calcEnergy(); + float average_power = (float)DRAMPower->getPower().average_power; + temperature = TemperatureController::getInstance().getTemperature(this->myChannel, average_power); + } else { + temperature = TemperatureController::getInstance().getTemperature(this->myChannel, 0); + } } return temperature; diff --git a/DRAMSys/simulator/src/error/errormodel.h b/DRAMSys/simulator/src/error/errormodel.h index a7950e55..2d5dfacf 100644 --- a/DRAMSys/simulator/src/error/errormodel.h +++ b/DRAMSys/simulator/src/error/errormodel.h @@ -37,12 +37,14 @@ #define ERRORMODEL_H #include "../controller/core/configuration/Configuration.h" #include "../common/xmlAddressdecoder.h" +#include "../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h" #include #include class errorModel { public: + errorModel(libDRAMPower *dp); errorModel(); ~errorModel(); @@ -55,6 +57,9 @@ class errorModel double getTemperature(void); private: + void init(void); + bool powerAnalysis; + libDRAMPower *DRAMPower; // Configuration Parameters: unsigned int busWidth; unsigned int burstLenght; diff --git a/DRAMSys/simulator/src/simulation/Dram.h b/DRAMSys/simulator/src/simulation/Dram.h index 49c5740e..f6ada6b6 100644 --- a/DRAMSys/simulator/src/simulation/Dram.h +++ b/DRAMSys/simulator/src/simulation/Dram.h @@ -172,7 +172,11 @@ struct Dram : sc_module { for (unsigned i = 0; i < Configuration::getInstance().memSpec.NumberOfBanks; i++) { errorModel *em; - em = new errorModel(); + if (powerAnalysis == true) { + em = new errorModel(DRAMPower); + } else { + em = new errorModel(); + } ememory.push_back(em); } } From 07fb5287b8f1ccdaad40fcc0db296c49f84a5208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 15 Oct 2015 12:10:01 +0200 Subject: [PATCH 22/39] Error model changed to avoid premature end of simulation. Check if the provided temperature and retention time are in a valid range that is covered by the input data stored in the errorMap. In case values are out of range the maximum values provided are used and debug messages are generated to alert the user. --- DRAMSys/simulator/src/error/errormodel.cpp | 86 +++++++++++----------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 736d30d6..6500d5ef 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -711,55 +711,55 @@ void errorModel::prepareWeakCells() // Retrieve number of flipping bits which fits best to temperature input and time since last refresh unsigned int errorModel::getNumberOfFlips(double temp, sc_time time) { - // Check if the provided temperature and time are in a valid range that - // is covered by the input data stored in the errorMap: - if(temp > maxTemperature) - { - SC_REPORT_FATAL("errormodel","temperature out of range"); + // Check if the provided temperature and retention time are in a valid + // range that is covered by the input data stored in the errorMap. + // In case values are out of range the maximum values provided are used + // (saturation) and debug messages are generated to alert the user. + if (temp > maxTemperature) { + temp = maxTemperature; + DebugManager::getInstance().printDebugMessage(name, "errormodel, temperature out of range."); } - else if(time > maxTime) - { - SC_REPORT_FATAL("errormodel","time out of range"); + + if (time > maxTime) { + time = maxTime; + DebugManager::getInstance().printDebugMessage(name, "errormodel, time out of range."); } - else + + // Find nearest temperature: + double nearestTemperature = 0; + for( const auto &i : errorMap ) { - // Find nearest temperature: - double nearestTemperature = 0; - for( const auto &i : errorMap ) + if(i.first >= temp) // for worst case reasons we go to the next bin { - if(i.first >= temp) // for worst case reasons we go to the next bin - { - nearestTemperature = i.first; - break; - } + nearestTemperature = i.first; + break; } - - // Find nearest time: - sc_time nearestTime; - for( const auto &i : errorMap[nearestTemperature]) - { - if(i.first >= time) // for worst case reasons we go to the next bin - { - nearestTime = i.first; - break; - } - } - - errors e = errorMap[nearestTemperature][nearestTime]; - - //std::stringstream msg; - //msg << "ACT/REF temp:" << temp - // << " time:" << time - // << " nearestTemp:" << nearestTemperature - // << " nearestTime:" << nearestTime - // << " ind:" << e.independent - // << " dep:" << e.dependent; - - //DebugManager::getInstance().printDebugMessage(name, msg.str()); - - return e.independent + e.dependent; } - return 0; + + // Find nearest time: + sc_time nearestTime; + for( const auto &i : errorMap[nearestTemperature]) + { + if(i.first >= time) // for worst case reasons we go to the next bin + { + nearestTime = i.first; + break; + } + } + + errors e = errorMap[nearestTemperature][nearestTime]; + + //std::stringstream msg; + //msg << "ACT/REF temp:" << temp + // << " time:" << time + // << " nearestTemp:" << nearestTemperature + // << " nearestTime:" << nearestTime + // << " ind:" << e.independent + // << " dep:" << e.dependent; + + //DebugManager::getInstance().printDebugMessage(name, msg.str()); + + return e.independent + e.dependent; } void errorModel::setContext(DecodedAddress addr) From 207ca1e5d0c409da2d6d5bac102f6559cff75496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Thu, 15 Oct 2015 16:28:15 +0200 Subject: [PATCH 23/39] The need of period adjustment is now evaluated every time the temperature is requested --- DRAMSys/simulator/src/error/errormodel.cpp | 4 ++-- .../src/simulation/TemperatureController.cpp | 22 +++++++++---------- .../src/simulation/TemperatureController.h | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 6500d5ef..0d1a42b4 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -717,12 +717,12 @@ unsigned int errorModel::getNumberOfFlips(double temp, sc_time time) // (saturation) and debug messages are generated to alert the user. if (temp > maxTemperature) { temp = maxTemperature; - DebugManager::getInstance().printDebugMessage(name, "errormodel, temperature out of range."); + //DebugManager::getInstance().printDebugMessage(name, "errormodel, temperature out of range."); } if (time > maxTime) { time = maxTime; - DebugManager::getInstance().printDebugMessage(name, "errormodel, time out of range."); + //DebugManager::getInstance().printDebugMessage(name, "errormodel, time out of range."); } // Find nearest temperature: diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index e30fc3f5..91cfb40c 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -56,6 +56,7 @@ double TemperatureController::getTemperature(int deviceId, float currentPower) if (dynamicTempSimEnabled == true) { currentPowerValues.at(deviceId) = currentPower; + checkPowerThreshold(deviceId); // FIXME using the static temperature value until the vector of // temperatures is filled @@ -82,6 +83,14 @@ void TemperatureController::updateTemperatures() temperaturesBuffer.clear(); } +void TemperatureController::checkPowerThreshold(int deviceId) +{ + if (std::abs(lastPowerValues.at(deviceId) - currentPowerValues.at(deviceId)) > powerThresholds.at(deviceId)) { + decreaseSimPeriod = true; + } + lastPowerValues.at(deviceId) = currentPowerValues.at(deviceId); +} + double TemperatureController::adjustThermalSimPeriod() { // Temperature Simulation Period Dynamic Adjustment @@ -110,19 +119,10 @@ double TemperatureController::adjustThermalSimPeriod() // again in steps of 'n/2' until it achieves the desired value given by // configuration or the described in 1.1 occurs. - bool decreaseSimPeriod = false; - - for (unsigned i = 0; i < currentPowerValues.size(); i++) { - if (std::abs(lastPowerValues.at(i) - currentPowerValues.at(i)) > powerThresholds.at(i)) { - cyclesSinceLastPeriodAdjust = 0; - decreaseSimPeriod = true; - } - } - - lastPowerValues = currentPowerValues; - if (decreaseSimPeriod == true) { period = period / periodAdjustFactor; + cyclesSinceLastPeriodAdjust = 0; + decreaseSimPeriod = false; printDebugMessage("Thermal Simulation period reduced to " + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); } else { if (period != targetPeriod) { diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index fe9b5335..f6e98387 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -79,6 +79,7 @@ public: // Substantial changes in power will trigger adjustments in the simulaiton period. Get the thresholds from config. powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds; + decreaseSimPeriod = false; periodAdjustFactor = Configuration::getInstance().temperatureSim.SimPeriodAdjustFactor; nPowStableCyclesToIncreasePeriod = Configuration::getInstance().temperatureSim.NPowStableCyclesToIncreasePeriod; cyclesSinceLastPeriodAdjust = 0; @@ -120,6 +121,8 @@ private: void temperatureThread(); void updateTemperatures(); double adjustThermalSimPeriod(); + void checkPowerThreshold(int deviceId); + bool decreaseSimPeriod; unsigned int periodAdjustFactor; unsigned int cyclesSinceLastPeriodAdjust; unsigned int nPowStableCyclesToIncreasePeriod; From 072cee7afcd87771175f80183bcad33ca4cc9585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Fri, 16 Oct 2015 15:41:46 +0200 Subject: [PATCH 24/39] Added support to temperature and power maps generation. --- .../resources/configs/temperature_sim/stack.stk | 4 +++- .../simulator/resources/simulations/sim-batch.xml | 2 ++ .../simulator/src/common/third_party/icewrapper | 2 +- .../core/configuration/Configuration.cpp | 4 ++++ .../core/configuration/temperatureSimConfig.h | 2 ++ .../src/simulation/TemperatureController.cpp | 5 +++++ .../src/simulation/TemperatureController.h | 15 +++++++++++++++ 7 files changed, 32 insertions(+), 2 deletions(-) diff --git a/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk b/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk index 338130b7..df1f506d 100755 --- a/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk +++ b/DRAMSys/simulator/resources/configs/temperature_sim/stack.stk @@ -28,7 +28,7 @@ die DRAM : dimensions : chip length 6100, width 10600 ; - cell length 100, width 100 ; + cell length 1000, width 1000 ; stack: die DRAM_DIE DRAM floorplan "./mem.flp" ; @@ -43,4 +43,6 @@ output: Tflpel(DRAM_DIE.channel1 , "temp_flp_element_ch1.txt" , average , slot ); Tflpel(DRAM_DIE.channel2 , "temp_flp_element_ch2.txt" , average , slot ); Tflpel(DRAM_DIE.channel3 , "temp_flp_element_ch3.txt" , average , slot ); + Tmap (DRAM_DIE, "output1.txt", slot) ; + Pmap (DRAM_DIE, "output2.txt", slot) ; diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index e4612577..977e01a5 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -21,6 +21,8 @@ + + diff --git a/DRAMSys/simulator/src/common/third_party/icewrapper b/DRAMSys/simulator/src/common/third_party/icewrapper index e84ff691..f118c42b 160000 --- a/DRAMSys/simulator/src/common/third_party/icewrapper +++ b/DRAMSys/simulator/src/common/third_party/icewrapper @@ -1 +1 @@ -Subproject commit e84ff691e99f7ed246ac85b76906961b061aaaf8 +Subproject commit f118c42b5ab865708d9ab1bd1383ce6c99189a8e diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp index 313f0f51..69315241 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.cpp @@ -178,6 +178,10 @@ void Configuration::setParameter(std::string name, std::string value) temperatureSim.SimPeriodAdjustFactor = std::stoi(value.c_str()); else if (name == "NPowStableCyclesToIncreasePeriod") temperatureSim.NPowStableCyclesToIncreasePeriod = std::stoi(value.c_str()); + else if (name == "GenerateTemperatureMap") + temperatureSim.GenerateTemperatureMap = string2bool(value); + else if (name == "GeneratePowerMap") + temperatureSim.GeneratePowerMap = string2bool(value); 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 141aea78..63f39b5f 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h +++ b/DRAMSys/simulator/src/controller/core/configuration/temperatureSimConfig.h @@ -60,6 +60,8 @@ struct TemperatureSimConfig { unsigned int IceServerPort; unsigned int SimPeriodAdjustFactor; unsigned int NPowStableCyclesToIncreasePeriod; + bool GenerateTemperatureMap; + bool GeneratePowerMap; // Power related information std::string powerInfoFile; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index 91cfb40c..2f67431a 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -76,6 +76,11 @@ void TemperatureController::updateTemperatures() thermalSimulation->sendPowerValues(¤tPowerValues); thermalSimulation->simulate(); thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TFLPEL, TDICE_OUTPUT_QUANTITY_AVERAGE); + + if (genTempMap == true) + thermalSimulation->getTemperatureMap(temperatureMapFile); + if (genPowerMap == true) + thermalSimulation->getPowerMap(powerMapFile); #endif // Save values just obtained for posterior use temperatureValues = temperaturesBuffer; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index f6e98387..26ece72d 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -40,6 +40,7 @@ #include #include #include +#include #include "../common/DebugManager.h" #include "../common/Utils.h" @@ -88,6 +89,15 @@ public: targetPeriod = Configuration::getInstance().temperatureSim.DynTemperatureSimPeriod; period = targetPeriod; t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; + + genTempMap = Configuration::getInstance().temperatureSim.GenerateTemperatureMap; + temperatureMapFile = "temperature_map.txt"; + std::remove(temperatureMapFile.c_str()); + + genPowerMap = Configuration::getInstance().temperatureSim.GeneratePowerMap; + powerMapFile = "power_map.txt"; + std::remove(powerMapFile.c_str()); + SC_THREAD(temperatureThread); } else { staticTemperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; @@ -127,6 +137,11 @@ private: unsigned int cyclesSinceLastPeriodAdjust; unsigned int nPowStableCyclesToIncreasePeriod; + bool genTempMap; + std::string temperatureMapFile; + bool genPowerMap; + std::string powerMapFile; + void printDebugMessage(std::string message); }; From 672f0abefe73515d99f95b4df9f07adca26bb8a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 19 Oct 2015 10:44:57 +0200 Subject: [PATCH 25/39] Temperature and power map files created with a timestamp --- .../simulator/src/common/third_party/icewrapper | 2 +- .../src/simulation/TemperatureController.cpp | 14 ++++++++++---- .../src/simulation/TemperatureController.h | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/DRAMSys/simulator/src/common/third_party/icewrapper b/DRAMSys/simulator/src/common/third_party/icewrapper index f118c42b..2179c985 160000 --- a/DRAMSys/simulator/src/common/third_party/icewrapper +++ b/DRAMSys/simulator/src/common/third_party/icewrapper @@ -1 +1 @@ -Subproject commit f118c42b5ab865708d9ab1bd1383ce6c99189a8e +Subproject commit 2179c985a0692e7ab5ec58c35eb7fa69f34c2252 diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.cpp b/DRAMSys/simulator/src/simulation/TemperatureController.cpp index 2f67431a..a0fda47f 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.cpp +++ b/DRAMSys/simulator/src/simulation/TemperatureController.cpp @@ -77,10 +77,16 @@ void TemperatureController::updateTemperatures() thermalSimulation->simulate(); thermalSimulation->getTemperature(temperaturesBuffer, TDICE_OUTPUT_INSTANT_SLOT, TDICE_OUTPUT_TYPE_TFLPEL, TDICE_OUTPUT_QUANTITY_AVERAGE); - if (genTempMap == true) - thermalSimulation->getTemperatureMap(temperatureMapFile); - if (genPowerMap == true) - thermalSimulation->getPowerMap(powerMapFile); + std::string mapfile; + sc_time ts = sc_time_stamp(); + if (genTempMap == true) { + mapfile = temperatureMapFile + "_" + std::to_string(ts.to_default_time_units()) + ".txt"; + thermalSimulation->getTemperatureMap(mapfile); + } + if (genPowerMap == true) { + mapfile = powerMapFile + "_" + std::to_string(ts.to_default_time_units()) + ".txt"; + thermalSimulation->getPowerMap(mapfile); + } #endif // Save values just obtained for posterior use temperatureValues = temperaturesBuffer; diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 26ece72d..c0650f6f 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -91,12 +91,12 @@ public: t_unit = Configuration::getInstance().temperatureSim.DynTemperatureSimUnit; genTempMap = Configuration::getInstance().temperatureSim.GenerateTemperatureMap; - temperatureMapFile = "temperature_map.txt"; - std::remove(temperatureMapFile.c_str()); + temperatureMapFile = "temperature_map"; + std::system("rm temperature_map*"); genPowerMap = Configuration::getInstance().temperatureSim.GeneratePowerMap; - powerMapFile = "power_map.txt"; - std::remove(powerMapFile.c_str()); + powerMapFile = "power_map"; + std::system("rm power_map*"); SC_THREAD(temperatureThread); } else { From bbcd7096b4a217efb85d8c93a6d4924a6fd54e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 19 Oct 2015 14:54:22 +0200 Subject: [PATCH 26/39] Adding scripts to repository. Matthias sent me these scripts by e-mail. This first commit adds them as they are (without any change). In the future we can use them to create a video based on the temperature maps generated by DRAMSys. --- .../scripts/video_rendering/Makefile | 9 ++ .../scripts/video_rendering/temperatur.job.pl | 135 ++++++++++++++++++ .../scripts/video_rendering/temperatur.pl | 67 +++++++++ 3 files changed, 211 insertions(+) create mode 100644 DRAMSys/simulator/resources/scripts/video_rendering/Makefile create mode 100644 DRAMSys/simulator/resources/scripts/video_rendering/temperatur.job.pl create mode 100644 DRAMSys/simulator/resources/scripts/video_rendering/temperatur.pl diff --git a/DRAMSys/simulator/resources/scripts/video_rendering/Makefile b/DRAMSys/simulator/resources/scripts/video_rendering/Makefile new file mode 100644 index 00000000..51190ca8 --- /dev/null +++ b/DRAMSys/simulator/resources/scripts/video_rendering/Makefile @@ -0,0 +1,9 @@ +all: + modulecmd bash load gnuplot/latest + modulecmd bash load image-magick/latest + ./temperatur.pl +movie: + ffmpeg -start_number 00000000 -i ../out/%08d.jpg -vcodec mpeg4 ../out.avi + +clean: + rm *.out *.err diff --git a/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.job.pl b/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.job.pl new file mode 100644 index 00000000..5c05db4c --- /dev/null +++ b/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.job.pl @@ -0,0 +1,135 @@ +#!/usr/bin/perl -w +use warnings; +use strict; +use File::Copy; + +my $file = shift; +my $id = shift; +my $samples = shift; +my $inputPath = "/gu2/jungma/thermal/in/out-backup"; +my $extractPath = "/gu2/jungma/thermal/tmp/$id"; + +print "Create TMP path... "; +system("mkdir $extractPath"); +print " done\n"; + +print "Extract... "; +system("tar -xf $inputPath/$file -C $extractPath"); +print " done\n"; + +print "Preprocessing... "; +system("sed '1d' $extractPath/out/output_core_die_full.txt > $extractPath/die0.txt"); +system("sed '1d' $extractPath/out/output_mem_die_1_full.txt > $extractPath/die1.txt"); +system("sed '1d' $extractPath/out/output_mem_die_2_full.txt > $extractPath/die2.txt"); +system("sed '1d' $extractPath/out/output_mem_die_3_full.txt > $extractPath/die3.txt"); +system("sed '1d' $extractPath/out/output_mem_die_4_full.txt > $extractPath/die4.txt"); +print " done\n"; + +print "Gnuplot..."; +open( my $GP, '|-', 'gnuplot' ); +print $GP " + reset + set terminal pngcairo size 500,500 enhanced font 'Verdana,10' + + set border linewidth 0 + unset key + unset colorbox + unset tics + set lmargin screen 0.0 + set rmargin screen 1.0 + set tmargin screen 1.0 + set bmargin screen 0.0 + + set pm3d map + set pm3d interpolate 2,2 + set cbrange [318.0:388.0] + + #set palette rgbformulae 22,13,-31 + set palette defined ( 0 \"blue\", 3 \"green\", 4 \"yellow\", 5 \"red\", 6 \"black\" ) + + set output '$extractPath/die0.png' + splot '$extractPath/die0.txt' matrix every ::1 + + set output '$extractPath/die1.png' + splot '$extractPath/die1.txt' matrix every ::1 + + set output '$extractPath/die2.png' + splot '$extractPath/die2.txt' matrix every ::1 + + set output '$extractPath/die3.png' + splot '$extractPath/die3.txt' matrix every ::1 + + set output '$extractPath/die4.png' + splot '$extractPath/die4.txt' matrix every ::1"; +close($GP); +print " done\n"; + +print "Wait for files... "; +while (1) { last if -e "$extractPath/die0.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die1.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die2.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die3.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die4.png"; print "."; sleep 1;} +print " done\n"; + +print "Composite ..."; +system("composite -gravity center constants/thermal_model_core.png $extractPath/die0.png $extractPath/die0b.png"); +system("composite -gravity center constants/thermal_model_dram_0_1.png $extractPath/die1.png $extractPath/die1b.png"); +system("composite -gravity center constants/thermal_model_dram_2_3.png $extractPath/die2.png $extractPath/die2b.png"); +system("composite -gravity center constants/thermal_model_dram_4_5.png $extractPath/die3.png $extractPath/die3b.png"); +system("composite -gravity center constants/thermal_model_dram_6_7.png $extractPath/die4.png $extractPath/die4b.png"); +print " done\n"; + +print "Wait for files... "; +while (1) { last if -e "$extractPath/die0b.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die1b.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die2b.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die3b.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die4b.png"; print "."; sleep 1;} +print " done\n"; + +print "Convert ..."; +system("convert $extractPath/die0b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die0c.png"); +system("convert $extractPath/die1b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die1c.png"); +system("convert $extractPath/die2b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die2c.png"); +system("convert $extractPath/die3b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die3c.png"); +system("convert $extractPath/die4b.png -alpha set -background none -shear 0x-40 -rotate 60 +repage -crop 1048x485+0+205 $extractPath/die4c.png"); +print " done\n"; + +print "Wait for files... "; +while (1) { last if -e "$extractPath/die0c.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die1c.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die2c.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die3c.png"; print "."; sleep 1;} +while (1) { last if -e "$extractPath/die4c.png"; print "."; sleep 1;} +print " done\n"; + +my $outFileName = sprintf("%08d", $id); + +print "Produce Output ..."; +system("convert -size 1048x1680 xc:black $extractPath/die0c.png -geometry +0+1200 -composite $extractPath/die1c.png -geometry +0+900 -composite $extractPath/die2c.png -geometry +0+600 -composite $extractPath/die3c.png -geometry +0+300 -composite $extractPath/die4c.png -composite $extractPath/a$outFileName.jpg"); + +while (1) { last if -e "$extractPath/a$outFileName.jpg"; print "."; sleep 1;} +system("convert $extractPath/a$outFileName.jpg -pointsize 80 -fill white -gravity northeast -draw \"text 20,20 '".$samples."ms'\" $extractPath/b$outFileName.jpg"); + +while (1) { last if -e "$extractPath/b$outFileName.jpg"; print "."; sleep 1;} +system("convert $extractPath/b$outFileName.jpg constants/legend/legend4.png +append ../out/$outFileName.jpg"); + +print " done\n"; + +print "Produce Samples ..."; +for(my $i = 0; $i < $samples-1; $i++) +{ + $id++; + my $outFileNameCopy = sprintf("%08d", $id); + copy("../out/$outFileName.jpg","../out/$outFileNameCopy.jpg"); +} +print " done\n"; + +# cleanup +print "Cleanup ... "; +while (1) { last if -e "/gu2/jungma/thermal/out/$outFileName.jpg"; print "."; sleep 1;} +system("rm -rf $extractPath"); +print " done\n"; + +##ffmpeg -start_number 00000000 -i %08d.jpg -vcodec mpeg4 test.avi diff --git a/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.pl b/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.pl new file mode 100644 index 00000000..11279c14 --- /dev/null +++ b/DRAMSys/simulator/resources/scripts/video_rendering/temperatur.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl -w +use warnings; +use strict; +use List::Util qw( min max ); + +#/Volumes/Etana_tmp2/tmp_sadri/backup/sep_16/log_smartbench_traces_50_cpu_1650_mhz_100_mhz_dram_100_mhz_sampling8X_bankwise_on_test/out-backup +my $inputPath = "../in/out-backup"; +my $extractPath = "../tmp"; +my $samplingFile = "../in/sampling"; + +# Read the input file names and store it in an array +opendir (DIR, $inputPath) or die $!; + +my @files; +my @sortetFiles; + +while (my $file = readdir(DIR)) +{ + push(@files, $file); +} + +@sortetFiles = sort @files; + + +print "Cleanup\n"; +system("rm -rf *.err *.out"); +system("rm -rf ../tmp/*"); +print "Load modules\n"; + + +# Estimate sampeling numbers + +open(SF,$samplingFile); + +my @refreshRates; + +while() +{ + $_ =~ /(\d+)\.0/; + my $rate = $1; + push(@refreshRates, $rate); +} + +print "Max. Rate:".max(@refreshRates)."\n"; +print "Min. Rate:".min(@refreshRates)."\n"; + +my $counter = 0; +my $i = 0; +# For each data package start one job! +foreach(@sortetFiles) +{ + my $file = $_; + + if($file =~ /(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)-(\d+)\.tgz/) + { + my $samples = $refreshRates[$i]; + system("bsub -W 00:05 ./temperatur.job.pl $file $counter $samples"); + $counter+=$samples; + $i++; + #if($i == 100) + #{ + # last; + #} + } +} + +##ffmpeg -start_number 00000000 -i %08d.jpg -vcodec mpeg4 test.avi From 8e64eee64d87aa514e66f40a7021a9c803ca6b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 20 Oct 2015 08:59:13 +0200 Subject: [PATCH 27/39] Get power values from DRAMPower if powerAnalysis and dynamic temperature simulation are activated --- DRAMSys/simulator/src/error/errormodel.cpp | 3 ++- DRAMSys/simulator/src/error/errormodel.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/error/errormodel.cpp b/DRAMSys/simulator/src/error/errormodel.cpp index 0d1a42b4..dc8be31b 100644 --- a/DRAMSys/simulator/src/error/errormodel.cpp +++ b/DRAMSys/simulator/src/error/errormodel.cpp @@ -44,6 +44,7 @@ void errorModel::init() { powerAnalysis = Configuration::getInstance().PowerAnalysis; + dynTemperatureSim = Configuration::getInstance().DynamicTemperatureSimulation; // Get Configuration parameters: busWidth = Configuration::getInstance().Buswidth; burstLenght = Configuration::getInstance().memSpec.BurstLength; @@ -512,7 +513,7 @@ double errorModel::getTemperature() double temperature = 89; if (this->myChannel != -1) { - if (powerAnalysis == true) { + if (dynTemperatureSim == true && powerAnalysis == true) { // TODO // check if this is best way to request information to DRAMPower. DRAMPower->updateCounters(true); diff --git a/DRAMSys/simulator/src/error/errormodel.h b/DRAMSys/simulator/src/error/errormodel.h index 2d5dfacf..5beff44c 100644 --- a/DRAMSys/simulator/src/error/errormodel.h +++ b/DRAMSys/simulator/src/error/errormodel.h @@ -60,6 +60,7 @@ class errorModel void init(void); bool powerAnalysis; libDRAMPower *DRAMPower; + bool dynTemperatureSim; // Configuration Parameters: unsigned int busWidth; unsigned int burstLenght; From 5ae04097b093c05efa9ab99dedc3079b1ecc3f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 20 Oct 2015 16:42:37 +0200 Subject: [PATCH 28/39] Avoid a warning when environment variable THERMALSIM is empty --- DRAMSys/dram.vp.system.pro | 4 ++++ DRAMSys/simulator/simulator.pro | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/DRAMSys/dram.vp.system.pro b/DRAMSys/dram.vp.system.pro index 37b7397b..5a29d611 100644 --- a/DRAMSys/dram.vp.system.pro +++ b/DRAMSys/dram.vp.system.pro @@ -1,6 +1,10 @@ TEMPLATE = subdirs thermalsim = $$(THERMALSIM) +isEmpty(thermalsim) { + thermalsim = false +} + $$eval(thermalsim) { message(Thermal Simulation Feature Enabled) diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index 9f18dd15..3c908dbe 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -135,6 +135,10 @@ HEADERS += \ src/error/errormodel.h thermalsim = $$(THERMALSIM) +isEmpty(thermalsim) { + thermalsim = false +} + $$eval(thermalsim) { message(Thermal Simulation Feature Enabled) From 1b0b2cc1d4d04f36546640ea72c663f692d1022a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 20 Oct 2015 16:43:42 +0200 Subject: [PATCH 29/39] Disabling temperature simulation and error model in default configuration. --- DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml | 2 +- DRAMSys/simulator/resources/simulations/sim-batch.xml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml index d0f996f0..7f8af9a8 100644 --- a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml +++ b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml @@ -9,7 +9,7 @@ - + - + @@ -39,7 +39,7 @@ - ../../../tests/error/test_error.stl + chstone-adpcm_32.stl From ff23c83991598aec8752ba9d624ca65db323dfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Fri, 23 Oct 2015 12:01:51 +0200 Subject: [PATCH 30/39] Readme file updated and small fix. Get the static temperature value from config and store it in the Temperature controller's internal structure always. --- .../simulator/src/simulation/TemperatureController.h | 3 ++- README.md | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index c0650f6f..1b7c7045 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -64,6 +64,8 @@ public: dynamicTempSimEnabled = Configuration::getInstance().DynamicTemperatureSimulation; + staticTemperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; + if (dynamicTempSimEnabled == true) { #ifdef THERMALSIM // Connect to the server @@ -100,7 +102,6 @@ public: SC_THREAD(temperatureThread); } else { - staticTemperature = Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue; printDebugMessage("Static temperature simulation. Temperature set to " + std::to_string(staticTemperature)); } } diff --git a/README.md b/README.md index f61e192d..91c6891c 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,8 @@ The DRAMSys' main configuration file is presented below. + + @@ -290,6 +292,8 @@ The XML code below shows a typic configuration: + + @@ -419,6 +423,12 @@ Below are listed the configuration sections and configuration fields. - 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 cycles with power stability (i.e., changes that do not exceed the thresholds) to start increasing the simulation period back to its configured value. + - *GenerateTemperatureMap* (boolean) + - "1": generate temperature map files during dynamic temperature simulation + - "0": do not generate temperature map files during dynamic temperature simulation + - *GeneratePowerMap* (boolean) + - "1": generate power map files during dynamic temperature simulation + - "0": do not generate power map files during dynamic temperature simulation - **Memory Specification** From 1beb3102a0ebce78f0075dd74256631ee329d2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 11 Nov 2015 11:09:22 +0100 Subject: [PATCH 31/39] IceWrapper submodule repo URL changed. Using the repo in github.com instead of github.rhrk.uni-kl.de. --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index b2cd2b65..cca77de2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,4 +6,4 @@ url = https://github.com/leethomason/tinyxml2.git [submodule "DRAMSys/simulator/src/common/third_party/icewrapper"] path = DRAMSys/simulator/src/common/third_party/icewrapper - url = git@git.rhrk.uni-kl.de:EIT-Wehn/dram.vp.icewrapper.git + url = git@github.com:myzinsky/IceWrapper.git From 7dbc2994a5c92808d96f32c32d71ec7ef5629bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 11 Nov 2015 11:20:30 +0100 Subject: [PATCH 32/39] IceWrapper repo url - using https version --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index cca77de2..29841795 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,4 +6,4 @@ url = https://github.com/leethomason/tinyxml2.git [submodule "DRAMSys/simulator/src/common/third_party/icewrapper"] path = DRAMSys/simulator/src/common/third_party/icewrapper - url = git@github.com:myzinsky/IceWrapper.git + url = https://github.com/myzinsky/IceWrapper.git From cef3f87eff8aac8fadb4297430d49802c8262be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 11 Nov 2015 12:03:43 +0100 Subject: [PATCH 33/39] Using rm -f to ignore non existent files --- DRAMSys/simulator/src/simulation/TemperatureController.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DRAMSys/simulator/src/simulation/TemperatureController.h b/DRAMSys/simulator/src/simulation/TemperatureController.h index 1b7c7045..871032a0 100644 --- a/DRAMSys/simulator/src/simulation/TemperatureController.h +++ b/DRAMSys/simulator/src/simulation/TemperatureController.h @@ -94,11 +94,11 @@ public: genTempMap = Configuration::getInstance().temperatureSim.GenerateTemperatureMap; temperatureMapFile = "temperature_map"; - std::system("rm temperature_map*"); + std::system("rm -f temperature_map*"); genPowerMap = Configuration::getInstance().temperatureSim.GeneratePowerMap; powerMapFile = "power_map"; - std::system("rm power_map*"); + std::system("rm -f power_map*"); SC_THREAD(temperatureThread); } else { From 2aeb2351c2dea65c31b09dd2c75f72b7467bd69e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 11 Nov 2015 18:39:47 +0100 Subject: [PATCH 34/39] The trace player will call payload.release() only after receiving the END_RESP message. --- DRAMSys/simulator/src/simulation/TracePlayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/simulation/TracePlayer.h b/DRAMSys/simulator/src/simulation/TracePlayer.h index a376a93a..45b3ddeb 100644 --- a/DRAMSys/simulator/src/simulation/TracePlayer.h +++ b/DRAMSys/simulator/src/simulation/TracePlayer.h @@ -159,10 +159,10 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload, const tlm_ // } sendToTarget(payload, END_RESP, SC_ZERO_TIME); - payload.release(); } else if (phase == END_RESP) { + payload.release(); } else { From a4f80b24be9ae142014e4af164f781a209cef892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Wed, 11 Nov 2015 18:58:37 +0100 Subject: [PATCH 35/39] Revert "The trace player will call payload.release() only after receiving the END_RESP message." This reverts commit 2aeb2351c2dea65c31b09dd2c75f72b7467bd69e. --- DRAMSys/simulator/src/simulation/TracePlayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DRAMSys/simulator/src/simulation/TracePlayer.h b/DRAMSys/simulator/src/simulation/TracePlayer.h index 45b3ddeb..a376a93a 100644 --- a/DRAMSys/simulator/src/simulation/TracePlayer.h +++ b/DRAMSys/simulator/src/simulation/TracePlayer.h @@ -159,10 +159,10 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload, const tlm_ // } sendToTarget(payload, END_RESP, SC_ZERO_TIME); + payload.release(); } else if (phase == END_RESP) { - payload.release(); } else { From 977d4eed327087ac1a8409cf1f92d667d8165753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 16 Nov 2015 20:32:34 +0100 Subject: [PATCH 36/39] Maximum number of transactions to generate backpressure in the controller is now 8. --- DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml | 2 +- .../simulator/src/controller/core/configuration/Configuration.h | 2 +- DRAMSys/tests/error/fr_fcfs.xml | 2 +- README.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml index 7f8af9a8..138518c2 100644 --- a/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml +++ b/DRAMSys/simulator/resources/configs/memconfigs/fr_fcfs.xml @@ -1,7 +1,7 @@ - + diff --git a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h index ab5b71fd..374edd69 100644 --- a/DRAMSys/simulator/src/controller/core/configuration/Configuration.h +++ b/DRAMSys/simulator/src/controller/core/configuration/Configuration.h @@ -63,7 +63,7 @@ struct Configuration //MemConfig bool BankwiseLogic = false; bool OpenPagePolicy = true; - unsigned int MaxNrOfTransactions = 50; + unsigned int MaxNrOfTransactions = 8; std::string Scheduler; unsigned int Capsize = 5; sc_time getPowerDownTimeout(){return powerDownTimeoutInClk*memSpec.clk;} diff --git a/DRAMSys/tests/error/fr_fcfs.xml b/DRAMSys/tests/error/fr_fcfs.xml index d0f996f0..04104bb3 100644 --- a/DRAMSys/tests/error/fr_fcfs.xml +++ b/DRAMSys/tests/error/fr_fcfs.xml @@ -1,7 +1,7 @@ - + diff --git a/README.md b/README.md index 91c6891c..5bff33c3 100644 --- a/README.md +++ b/README.md @@ -225,7 +225,7 @@ Enable the error model in fr_fcfs.xml. - + From c23c6311c7c35002bb2bf91c24db7751ce867c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Mon, 16 Nov 2015 20:36:03 +0100 Subject: [PATCH 37/39] FIFO strict scheduler is now working properly. Summary: - The code was simplified - Using a deque instead of a vector to implement the FIFO. - Fixed a bug related to the removal of requests (payloads) from the FIFO. It was possible that old requests were not properly removed and then processed again after the memory manager had free()d the payload (and its extensions) generating a segmentation fault. --- .../resources/simulations/sim-batch.xml | 2 +- DRAMSys/simulator/src/controller/Controller.h | 13 +- .../src/controller/scheduler/FifoStrict.cpp | 128 +++++++++--------- .../src/controller/scheduler/FifoStrict.h | 23 ++-- 4 files changed, 78 insertions(+), 88 deletions(-) diff --git a/DRAMSys/simulator/resources/simulations/sim-batch.xml b/DRAMSys/simulator/resources/simulations/sim-batch.xml index c3ed7cbd..fbd50bf4 100644 --- a/DRAMSys/simulator/resources/simulations/sim-batch.xml +++ b/DRAMSys/simulator/resources/simulations/sim-batch.xml @@ -34,7 +34,7 @@ - + diff --git a/DRAMSys/simulator/src/controller/Controller.h b/DRAMSys/simulator/src/controller/Controller.h index 9889a697..01cf7c2a 100644 --- a/DRAMSys/simulator/src/controller/Controller.h +++ b/DRAMSys/simulator/src/controller/Controller.h @@ -151,7 +151,7 @@ void Controller::buildScheduler() } else if (selectedScheduler == "FIFO_STRICT") { - scheduler = new FifoStrict(*this, *controllerCore); + scheduler = new FifoStrict(*controllerCore); } else if (selectedScheduler == "FR_FCFS") { @@ -316,16 +316,7 @@ void Controller::controllerCorePEQCallback(tlm_generic_payload &payloa if (phase == BEGIN_RD || phase == BEGIN_WR) { - if(Configuration::getInstance().Scheduler == "FIFO_STRICT") - { - // special case for the Fifo_strict scheduler, because it may have to unblock - // the current front element - dynamic_cast(scheduler)->NotifyBeginRDWR(); - } - else - { - scheduleNextFromScheduler(DramExtension::getBank(payload)); - } + scheduleNextFromScheduler(DramExtension::getBank(payload)); } else if (phase == BEGIN_REFB) printDebugMessage("Entering REFB on bank " + to_string(bank.ID())); diff --git a/DRAMSys/simulator/src/controller/scheduler/FifoStrict.cpp b/DRAMSys/simulator/src/controller/scheduler/FifoStrict.cpp index 6b6244b4..4897b796 100644 --- a/DRAMSys/simulator/src/controller/scheduler/FifoStrict.cpp +++ b/DRAMSys/simulator/src/controller/scheduler/FifoStrict.cpp @@ -37,77 +37,83 @@ #include "FifoStrict.h" -void FifoStrict::schedule(gp *payload) +void FifoStrict::schedule(tlm::tlm_generic_payload *payload) { - buffer.push_back(payload); - printDebugMessage("New payload scheduled. Total number " + std::to_string(buffer.size()) + "\n"); -} - -void FifoStrict::printFrontElementState() -{ - if(buffer.size() > 0) - { - printDebugMessage("Front element state - Bank: " + DramExtension::getBank(buffer.front()).toString() + " Operation: " + - commandToString(getNextCommand(*buffer.front())) + "\n"); - } - else - { - printDebugMessage("No fron element. Buffer is empty \n "); - } -} - -void FifoStrict::NotifyBeginRDWR() -{ - buffer.erase(buffer.begin()); - printDebugMessage("Front element finished. New front Element: "); - printFrontElementState(); - - if(buffer.size() > 0) - { - // If the new front element was orginally blocked, because it had to wait on the old front element, we have to call - // controller.scheduleNextFromScheduler explicitly, otherwise there will be a deadlock in the system - controller.scheduleNextFromScheduler(DramExtension::getBank(buffer.front())); - } + Bank bank = DramExtension::getExtension(payload).getBank(); + buffer.push_back(std::pair(bank, payload)); } std::pair FifoStrict::getNextRequest(Bank bank) { - if(buffer.empty()) - { - return pair(Command::NOP, NULL); - } + if (!buffer.empty()) { - else if(DramExtension::getBank(buffer.front()) == bank) - { - Command command = getNextCommand(*buffer.front()); - pair result(command, buffer.front()); - printDebugMessage("Operation for front Element scheduled. "); - printFrontElementState(); + if (buffer.front().first == bank) { + // The next request in the FIFO is for the bank passed as parameter - return result; - } - else - { - for(unsigned int i = 1; i < buffer.size(); ++i) - { - if(DramExtension::getBank(buffer[i]) == bank) - { - Command command = getNextCommand(*buffer[i]); + tlm::tlm_generic_payload *payload = buffer.front().second; - // RD/WR operations have to be strictly in order across banks, so only allow progress on commands - // other than RD/WR commands. - if(commandIsIn(command, {Command::Read, Command::Write, Command::ReadA, Command::WriteA})) - { - printDebugMessage("Current queue element " + std::to_string(i) + " blocked. Waiting for earlier rd/wr to finish\n"); - return pair(Command::NOP, NULL); - } - else - { - return pair(command, buffer[i]); + // For a given request (a given payload) one or more commands will + // be sent to the DRAM in order to process it. + // + // getNextRequest() may be called more than once for the same + // enqueued request until the appropriate sequence of commands is + // sent to the DRAM. + // + // Every time getNextRequest() it is called it calls + // getNextCommand() that returns the suitable command to be sent + // to the DRAM. + // + // getNextCommand() returns the proper command based on the + // internal status of the DRAM. + // + // In the worst case getNextCommand() need to be called three + // times for a given element in the requests queue: first for + // precharge, second for activate and finally for read or write + // (accordingly the nature of the request). In contrast, for the + // case of an already open row (due to a previous request) the + // command itself could be directly issued. + // + Command command = IScheduler::getNextCommand(*payload); + + if(commandIsIn(command, {Command::Read, Command::Write, Command::ReadA, Command::WriteA})) { + buffer.pop_front(); + } + + return pair(command, payload); + + } else { + // The next request in the FIFO is NOT for the bank passed as parameter. + + // Search for the next request related to the bank passed as parameter. + for (auto req = buffer.begin(); req != buffer.end(); req++) { + if (req->first == bank) { + // Found a request to this bank in the queue + tlm::tlm_generic_payload *payload = req->second; + + // Get the appropriate command to be sent to the DRAM + // regarding this request. + // + // Commands other than read and write will be issued. + // Reads and writes will not be issued since this + // scheduler executes all read and writes in a strict + // order. + Command command = getNextCommand(*payload); + if(commandIsIn(command, {Command::Read, Command::Write, Command::ReadA, Command::WriteA})) { + // Reads and writes must be executed in order. Then if + // the next command for this request is read or write + // NOP will be returned and no operation will be + // performed. + return pair(Command::NOP, NULL); + } else { + // Commands other than read and write are issued normally. + return pair(command, payload); + } } } } - - return pair(Command::NOP, NULL); } + + // The FIFO is empty + return pair(Command::NOP, NULL); } + diff --git a/DRAMSys/simulator/src/controller/scheduler/FifoStrict.h b/DRAMSys/simulator/src/controller/scheduler/FifoStrict.h index e46add42..43f45d73 100644 --- a/DRAMSys/simulator/src/controller/scheduler/FifoStrict.h +++ b/DRAMSys/simulator/src/controller/scheduler/FifoStrict.h @@ -38,33 +38,26 @@ #ifndef FIFOSTRICT_H #define FIFOSTRICT_H -#include "../core/ControllerCore.h" -#include "../Command.h" -#include "../../common/dramExtension.h" -#include "IScheduler.h" #include #include #include +#include "../core/ControllerCore.h" +#include "../Command.h" +#include "IScheduler.h" + class FifoStrict : public IScheduler { public: - FifoStrict(IController &controller,ControllerCore &controllerCore) : - IScheduler(controllerCore), controller(controller) - {} - virtual ~FifoStrict() - {} + FifoStrict(ControllerCore &controllerCore) : IScheduler(controllerCore) {} + virtual ~FifoStrict() {} void schedule(gp* payload) override; std::pair getNextRequest(Bank bank) override; - void NotifyBeginRDWR(); - void NotifyBeginRD(); private: - std::vector buffer; - IController &controller; - void printFrontElementState(); + std::deque> buffer; }; +#endif /* FIFOSTRICT_H */ -#endif // FIFOSTRICT_H From 5ab6e88ab57be6aa67ff9673cc2e07fecde9cc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89der=20F=2E=20Zulian?= Date: Tue, 17 Nov 2015 11:51:12 +0100 Subject: [PATCH 38/39] FR_FCFS default storage mode changed back to "NoStorage". It was an overcommit (I forgot to change it back ;) ). --- DRAMSys/tests/error/fr_fcfs.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DRAMSys/tests/error/fr_fcfs.xml b/DRAMSys/tests/error/fr_fcfs.xml index 04104bb3..138518c2 100644 --- a/DRAMSys/tests/error/fr_fcfs.xml +++ b/DRAMSys/tests/error/fr_fcfs.xml @@ -9,7 +9,7 @@ - +