Code formatting.

This commit is contained in:
Lukas Steiner
2020-05-27 11:41:30 +02:00
parent 0de8ababfa
commit dcc23198b3
6 changed files with 454 additions and 476 deletions

View File

@@ -152,31 +152,31 @@ void Configuration::setParameter(std::string name, nlohmann::json value)
if (value != "Celsius" && value != "Fahrenheit" && value != "Kelvin")
SC_REPORT_FATAL("Configuration",
("Invalid value for parameter " + name + ".").c_str());
temperatureSim.TemperatureScale = value;
temperatureSim.temperatureScale = value;
}
else if (name == "StaticTemperatureDefaultValue")
temperatureSim.StaticTemperatureDefaultValue = value;
temperatureSim.staticTemperatureDefaultValue = value;
else if (name == "ThermalSimPeriod")
temperatureSim.ThermalSimPeriod = value;
temperatureSim.thermalSimPeriod = value;
else if (name == "ThermalSimUnit")
temperatureSim.ThermalSimUnit = string2TimeUnit(value);
temperatureSim.thermalSimUnit = string2TimeUnit(value);
else if (name == "PowerInfoFile")
{
temperatureSim.powerInfoFile = value;
temperatureSim.parsePowerInfoFile();
}
else if (name == "IceServerIp")
temperatureSim.IceServerIp = value;
temperatureSim.iceServerIp = value;
else if (name == "IceServerPort")
temperatureSim.IceServerPort = value;
temperatureSim.iceServerPort = value;
else if (name == "SimPeriodAdjustFactor")
temperatureSim.SimPeriodAdjustFactor = value;
temperatureSim.simPeriodAdjustFactor = value;
else if (name == "NPowStableCyclesToIncreasePeriod")
temperatureSim.NPowStableCyclesToIncreasePeriod = value;
temperatureSim.nPowStableCyclesToIncreasePeriod = value;
else if (name == "GenerateTemperatureMap")
temperatureSim.GenerateTemperatureMap = value;
temperatureSim.generateTemperatureMap = value;
else if (name == "GeneratePowerMap")
temperatureSim.GeneratePowerMap = value;
temperatureSim.generatePowerMap = value;
else
SC_REPORT_FATAL("Configuration",
("Parameter " + name + " not defined in Configuration").c_str());

File diff suppressed because it is too large Load Diff

View File

@@ -62,30 +62,28 @@ public:
static void loadSimConfig(Configuration &config, std::string simconfigUri);
static void loadMemSpec(Configuration &config, std::string memspecUri);
static void loadMemSpec(Configuration &config, nlohmann::json::object_t *memspec);
static void loadTemperatureSimConfig(Configuration &config,
std::string simconfigUri);
private:
ConfigurationLoader() {}
static void loadConfigJson(Configuration &config, nlohmann::json::object_t *configNode);
// Loads common config of DRAMs
static void loadCommons(Configuration &config, nlohmann::json::object_t *memspec);
static void loadCommons(Configuration &config, nlohmann::json &memspec);
// Load specific config
static void loadDDR3(Configuration &config, nlohmann::json::object_t *memspec);
static void loadDDR4(Configuration &config, nlohmann::json::object_t *memspec);
static void loadLPDDR4(Configuration &config, nlohmann::json::object_t *memspec);
static void loadWideIO(Configuration &config, nlohmann::json::object_t *memspec);
static void loadWideIO2(Configuration &config, nlohmann::json::object_t *memspec);
static void loadHBM2(Configuration &config, nlohmann::json::object_t *memspec);
static void loadGDDR5(Configuration &config, nlohmann::json::object_t *memspec);
static void loadGDDR5X(Configuration &config, nlohmann::json::object_t *memspec);
static void loadGDDR6(Configuration &config, nlohmann::json::object_t *memspec);
static void loadDDR3(Configuration &config, nlohmann::json &memspec);
static void loadDDR4(Configuration &config, nlohmann::json &memspec);
static void loadLPDDR4(Configuration &config, nlohmann::json &memspec);
static void loadWideIO(Configuration &config, nlohmann::json &memspec);
static void loadWideIO2(Configuration &config, nlohmann::json &memspec);
static void loadHBM2(Configuration &config, nlohmann::json &memspec);
static void loadGDDR5(Configuration &config, nlohmann::json &memspec);
static void loadGDDR5X(Configuration &config, nlohmann::json &memspec);
static void loadGDDR6(Configuration &config, nlohmann::json &memspec);
static unsigned int uIntParameter(nlohmann::json obj, std::string name);
static double doubleParameter(nlohmann::json obj, std::string name);
static std::string stringParameter(nlohmann::json obj, std::string name);
static unsigned int parseUint(nlohmann::json &obj, std::string name);
static double parseUdouble(nlohmann::json &obj, std::string name);
static std::string parseString(nlohmann::json &obj, std::string name);
};

View File

@@ -47,7 +47,7 @@
struct TemperatureSimConfig
{
// Temperature Scale
std::string TemperatureScale;
std::string temperatureScale;
std::string pathToResources;
void setPathToResources(std::string path)
@@ -56,17 +56,17 @@ struct TemperatureSimConfig
}
// Static Temperature Simulation parameters
int StaticTemperatureDefaultValue;
int staticTemperatureDefaultValue;
// Thermal Simulation parameters
double ThermalSimPeriod;
enum sc_time_unit ThermalSimUnit;
std::string IceServerIp;
unsigned int IceServerPort;
unsigned int SimPeriodAdjustFactor;
unsigned int NPowStableCyclesToIncreasePeriod;
bool GenerateTemperatureMap;
bool GeneratePowerMap;
double thermalSimPeriod;
enum sc_time_unit thermalSimUnit;
std::string iceServerIp;
unsigned int iceServerPort;
unsigned int simPeriodAdjustFactor;
unsigned int nPowStableCyclesToIncreasePeriod;
bool generateTemperatureMap;
bool generatePowerMap;
// Power related information
std::string powerInfoFile;
@@ -78,51 +78,54 @@ struct TemperatureSimConfig
PRINTDEBUGMESSAGE("TemperatureSimConfig", "Power Info File: " + powerInfoFile);
powerInfoFile = pathToResources
+ "/configs/thermalsim/"
+ powerInfoFile;
+ "/configs/thermalsim/"
+ powerInfoFile;
// Load the JSON file into memory and parse it
nlohmann::json powInfoElem = parseJSON(powerInfoFile);
nlohmann::json powInfoElem = parseJSON(powerInfoFile);
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();
float pow = value["init_pow"];
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)
float thr = value["threshold"];
powerThresholds.push_back(thr);
}
}
showTemperatureSimConfig();
}
void showTemperatureSimConfig()
if (powInfoElem["powerInfo"].empty())
{
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));
// 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();
float pow = value["init_pow"];
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)
float thr = value["threshold"];
powerThresholds.push_back(thr);
}
}
};
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

View File

@@ -43,7 +43,6 @@
#include <stdexcept>
#include "DRAMSys.h"
#include "Setup.h"
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
#include "../common/TlmRecorder.h"
#include "../common/DebugManager.h"

View File

@@ -59,18 +59,18 @@ public:
}
SC_CTOR(TemperatureController) {
temperatureScale = Configuration::getInstance().temperatureSim.TemperatureScale;
temperatureScale = Configuration::getInstance().temperatureSim.temperatureScale;
dynamicTempSimEnabled = Configuration::getInstance().thermalSimulation;
staticTemperature =
Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue;
Configuration::getInstance().temperatureSim.staticTemperatureDefaultValue;
if (dynamicTempSimEnabled == true) {
#ifdef THERMALSIM
// Connect to the server
std::string ip = Configuration::getInstance().temperatureSim.IceServerIp;
unsigned int port = Configuration::getInstance().temperatureSim.IceServerPort;
std::string ip = Configuration::getInstance().temperatureSim.iceServerIp;
unsigned int port = Configuration::getInstance().temperatureSim.iceServerPort;
thermalSimulation = new IceWrapper(ip, port);
PRINTDEBUGMESSAGE(name(), "Dynamic temperature simulation. Server @ "
+ ip + ":" + std::to_string(port));
@@ -87,21 +87,21 @@ public:
powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds;
decreaseSimPeriod = false;
periodAdjustFactor =
Configuration::getInstance().temperatureSim.SimPeriodAdjustFactor;
Configuration::getInstance().temperatureSim.simPeriodAdjustFactor;
nPowStableCyclesToIncreasePeriod =
Configuration::getInstance().temperatureSim.NPowStableCyclesToIncreasePeriod;
Configuration::getInstance().temperatureSim.nPowStableCyclesToIncreasePeriod;
cyclesSinceLastPeriodAdjust = 0;
// Get the target period for the thermal simulation from config.
targetPeriod = Configuration::getInstance().temperatureSim.ThermalSimPeriod;
targetPeriod = Configuration::getInstance().temperatureSim.thermalSimPeriod;
period = targetPeriod;
t_unit = Configuration::getInstance().temperatureSim.ThermalSimUnit;
t_unit = Configuration::getInstance().temperatureSim.thermalSimUnit;
genTempMap = Configuration::getInstance().temperatureSim.GenerateTemperatureMap;
genTempMap = Configuration::getInstance().temperatureSim.generateTemperatureMap;
temperatureMapFile = "temperature_map";
std::system("rm -f temperature_map*");
genPowerMap = Configuration::getInstance().temperatureSim.GeneratePowerMap;
genPowerMap = Configuration::getInstance().temperatureSim.generatePowerMap;
powerMapFile = "power_map";
std::system("rm -f power_map*");