Get power thresholds for temperature simulation from a xml file

This commit is contained in:
Éder F. Zulian
2015-09-29 17:39:17 +02:00
parent ae6e1e1040
commit 1160f575dc
8 changed files with 136 additions and 11 deletions

View File

@@ -0,0 +1,8 @@
<power_thresholds>
<cpu id="0" value="1.0" />
<cpu id="1" value="2.0" />
<gpu id="0" value="2.0" />
<dram id="2" value="5.0" />
<dram id="3" value="1.0" />
</power_thresholds>

View File

@@ -15,9 +15,7 @@
<StaticTemperatureDefaultValue value="89" />
<DynTemperatureSimPeriod value="100" />
<DynTemperatureSimUnit value="ms" />
<!--
<PowerThresholdsFile src="../../DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml"/>
-->
<PowerThresholdsFile value="../../DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml"/>
</temperature_simconfig>
<memspecs>

View File

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

View File

@@ -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<std::string, std::string> parameterMa
}
}

View File

@@ -41,6 +41,7 @@
#include <systemc.h>
#include <string>
#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();

View File

@@ -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 <systemc.h>
#include <iostream>
#include <string>
#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<int, float> cpuPowerThresholds;
std::map<int, float> gpuPowerThresholds;
std::map<int, float> 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<int, float>::value_type(id, thr));
} else if (name == "gpu") {
gpuPowerThresholds.insert(std::map<int, float>::value_type(id, thr));
} else if (name == "dram") {
dramPowerThresholds.insert(std::map<int, float>::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_ */

View File

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

View File

@@ -1,12 +1,22 @@
<simulation>
<!-- General Simulator Configuration (used for all simulation setups) -->
<simconfig>
<Debug value="0" />
<DatabaseRecording value="0" />
<PowerAnalysis value="1" />
<NumberOfTracePlayers value="1"/>
<NumberOfMemChannels value="4"/>
<ControllerCoreDisableRefresh value="0"/>
<DynamicTemperatureSimulation value="0"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->
<temperature_simconfig>
<StaticTemperatureDefaultValue value="89" />
<DynTemperatureSimPeriod value="100" />
<DynTemperatureSimUnit value="ms" />
</temperature_simconfig>
<memspecs>
<memspec src="../../DRAMSys/tests/error/WideIO.xml"></memspec>
</memspecs>