Temperature Controller skeleton

This commit is contained in:
Éder F. Zulian
2015-09-30 17:42:56 +02:00
parent 4c82592d0a
commit f6e59d5c04
9 changed files with 237 additions and 32 deletions

View File

@@ -7,15 +7,17 @@
<NumberOfTracePlayers value="4"/>
<NumberOfMemChannels value="4"/>
<ControllerCoreDisableRefresh value="0"/>
<DynamicTemperatureSimulation value="0"/>
<DynamicTemperatureSimulation value="1"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->
<temperature_simconfig>
<StaticTemperatureDefaultValue value="89" />
<DynTemperatureSimPeriod value="100" />
<DynTemperatureSimUnit value="ms" />
<DynTemperatureSimUnit value="us" />
<PowerThresholdsFile value="../../DRAMSys/simulator/resources/configs/temperature_sim/power_thresholds.xml"/>
<IceServerIp value="127.0.0.1" />
<IceServerPort value="11880" />
</temperature_simconfig>
<memspecs>

View File

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

View File

@@ -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());

View File

@@ -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<int, float> 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)

View File

@@ -35,14 +35,16 @@
#include "errormodel.h"
#include "../common/DebugManager.h"
#include "../simulation/TemperatureController.h"
#include <random>
#include <chrono>
#include <bitset>
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;
}

View File

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

View File

@@ -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<Device> &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<Device> &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;

View File

@@ -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<float> 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<float> 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);
}

View File

@@ -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 <systemc.h>
#include <iostream>
#include <string>
#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_ */