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)