diff --git a/DRAMSys/library/resources/configs/thermalsim/config.json b/DRAMSys/library/resources/configs/thermalsim/config.json index 023184a6..03064d1b 100644 --- a/DRAMSys/library/resources/configs/thermalsim/config.json +++ b/DRAMSys/library/resources/configs/thermalsim/config.json @@ -4,7 +4,7 @@ "StaticTemperatureDefaultValue": "89", "ThermalSimPeriod":"100", "ThermalSimUnit":"us", - "PowerInfoFile": "powerInfo.xml", + "PowerInfoFile": "powerInfo.json", "IceServerIp": "127.0.0.1", "IceServerPort": "11880", "SimPeriodAdjustFactor" : "10", diff --git a/DRAMSys/library/resources/configs/thermalsim/powerInfo.json b/DRAMSys/library/resources/configs/thermalsim/powerInfo.json new file mode 100644 index 00000000..80c12d8e --- /dev/null +++ b/DRAMSys/library/resources/configs/thermalsim/powerInfo.json @@ -0,0 +1,20 @@ +{ + "powerInfo": { + "dram_die_channel0": { + "init_pow": "0", + "threshold": "1.0" + }, + "dram_die_channel1": { + "init_pow": "0", + "threshold": "1.0" + }, + "dram_die_channel2": { + "init_pow": "0", + "threshold": "1.0" + }, + "dram_die_channel3": { + "init_pow": "0", + "threshold": "1.0" + } + } +} diff --git a/DRAMSys/library/src/configuration/TemperatureSimConfig.h b/DRAMSys/library/src/configuration/TemperatureSimConfig.h index a0505bbf..a7e9eb38 100644 --- a/DRAMSys/library/src/configuration/TemperatureSimConfig.h +++ b/DRAMSys/library/src/configuration/TemperatureSimConfig.h @@ -82,49 +82,49 @@ struct TemperatureSimConfig + "/configs/thermalsim/" + powerInfoFile; - // Load the XML file into memory and parse it - tinyxml2::XMLDocument xml; - loadXML(powerInfoFile, xml); - tinyxml2::XMLElement *powInfoElem = xml.FirstChildElement("powerInfo"); + // Load the JSON file into memory and parse it + nlohmann::json powInfoElem = nlohmann::json::parse(std::ifstream(powerInfoFile)); - if (powInfoElem == NULL) { - // Invalid file - std::string errormsg = "Invalid Power Info File " + powerInfoFile; - PRINTDEBUGMESSAGE("TemperatureSimConfig", errormsg); - SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str()); + if (powInfoElem["powerInfo"].empty()){ + // Invalid file + std::string errormsg = "Invalid Power Info File " + powerInfoFile; + PRINTDEBUGMESSAGE("TemperatureSimConfig", errormsg); + SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str()); + } + else { + for ( auto it: powInfoElem["powerInfo"].items() ){ + + // Load initial power values for all devices + auto value= it.value(); + std::string init_pow_str = value["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 = value["threshold"]; + float thr = std::stof(thr_str); + powerThresholds.push_back(thr); + } + } + showTemperatureSimConfig(); } - 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); + void showTemperatureSimConfig() + { + int i __attribute__((unused)) = 0; + for (auto e __attribute__((unused)) : powerInitialValues) { + PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerInitialValues[" + + std::to_string(i++) + "]: " + std::to_string(e)); + } + i = 0; + for (auto e __attribute__((unused)) : powerThresholds) { + PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerThreshold[" + + std::to_string(i++) + "]: " + std::to_string(e)); + } } - - showTemperatureSimConfig(); - } - - void showTemperatureSimConfig() - { - int i __attribute__((unused)) = 0; - for (auto e __attribute__((unused)) : powerInitialValues) { - PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerInitialValues[" - + std::to_string(i++) + "]: " + std::to_string(e)); - } - i = 0; - for (auto e __attribute__((unused)) : powerThresholds) { - PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerThreshold[" - + std::to_string(i++) + "]: " + std::to_string(e)); - } - } -}; + }; #endif // TEMPERATURESIMCONFIG_H