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 @@
+
+
+
+
+
+
+
+
+
+