Code formatting.
This commit is contained in:
@@ -152,31 +152,31 @@ void Configuration::setParameter(std::string name, nlohmann::json value)
|
|||||||
if (value != "Celsius" && value != "Fahrenheit" && value != "Kelvin")
|
if (value != "Celsius" && value != "Fahrenheit" && value != "Kelvin")
|
||||||
SC_REPORT_FATAL("Configuration",
|
SC_REPORT_FATAL("Configuration",
|
||||||
("Invalid value for parameter " + name + ".").c_str());
|
("Invalid value for parameter " + name + ".").c_str());
|
||||||
temperatureSim.TemperatureScale = value;
|
temperatureSim.temperatureScale = value;
|
||||||
}
|
}
|
||||||
else if (name == "StaticTemperatureDefaultValue")
|
else if (name == "StaticTemperatureDefaultValue")
|
||||||
temperatureSim.StaticTemperatureDefaultValue = value;
|
temperatureSim.staticTemperatureDefaultValue = value;
|
||||||
else if (name == "ThermalSimPeriod")
|
else if (name == "ThermalSimPeriod")
|
||||||
temperatureSim.ThermalSimPeriod = value;
|
temperatureSim.thermalSimPeriod = value;
|
||||||
else if (name == "ThermalSimUnit")
|
else if (name == "ThermalSimUnit")
|
||||||
temperatureSim.ThermalSimUnit = string2TimeUnit(value);
|
temperatureSim.thermalSimUnit = string2TimeUnit(value);
|
||||||
else if (name == "PowerInfoFile")
|
else if (name == "PowerInfoFile")
|
||||||
{
|
{
|
||||||
temperatureSim.powerInfoFile = value;
|
temperatureSim.powerInfoFile = value;
|
||||||
temperatureSim.parsePowerInfoFile();
|
temperatureSim.parsePowerInfoFile();
|
||||||
}
|
}
|
||||||
else if (name == "IceServerIp")
|
else if (name == "IceServerIp")
|
||||||
temperatureSim.IceServerIp = value;
|
temperatureSim.iceServerIp = value;
|
||||||
else if (name == "IceServerPort")
|
else if (name == "IceServerPort")
|
||||||
temperatureSim.IceServerPort = value;
|
temperatureSim.iceServerPort = value;
|
||||||
else if (name == "SimPeriodAdjustFactor")
|
else if (name == "SimPeriodAdjustFactor")
|
||||||
temperatureSim.SimPeriodAdjustFactor = value;
|
temperatureSim.simPeriodAdjustFactor = value;
|
||||||
else if (name == "NPowStableCyclesToIncreasePeriod")
|
else if (name == "NPowStableCyclesToIncreasePeriod")
|
||||||
temperatureSim.NPowStableCyclesToIncreasePeriod = value;
|
temperatureSim.nPowStableCyclesToIncreasePeriod = value;
|
||||||
else if (name == "GenerateTemperatureMap")
|
else if (name == "GenerateTemperatureMap")
|
||||||
temperatureSim.GenerateTemperatureMap = value;
|
temperatureSim.generateTemperatureMap = value;
|
||||||
else if (name == "GeneratePowerMap")
|
else if (name == "GeneratePowerMap")
|
||||||
temperatureSim.GeneratePowerMap = value;
|
temperatureSim.generatePowerMap = value;
|
||||||
else
|
else
|
||||||
SC_REPORT_FATAL("Configuration",
|
SC_REPORT_FATAL("Configuration",
|
||||||
("Parameter " + name + " not defined in Configuration").c_str());
|
("Parameter " + name + " not defined in Configuration").c_str());
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -62,30 +62,28 @@ public:
|
|||||||
static void loadSimConfig(Configuration &config, std::string simconfigUri);
|
static void loadSimConfig(Configuration &config, std::string simconfigUri);
|
||||||
|
|
||||||
static void loadMemSpec(Configuration &config, std::string memspecUri);
|
static void loadMemSpec(Configuration &config, std::string memspecUri);
|
||||||
static void loadMemSpec(Configuration &config, nlohmann::json::object_t *memspec);
|
|
||||||
|
|
||||||
static void loadTemperatureSimConfig(Configuration &config,
|
static void loadTemperatureSimConfig(Configuration &config,
|
||||||
std::string simconfigUri);
|
std::string simconfigUri);
|
||||||
private:
|
private:
|
||||||
ConfigurationLoader() {}
|
ConfigurationLoader() {}
|
||||||
static void loadConfigJson(Configuration &config, nlohmann::json::object_t *configNode);
|
|
||||||
|
|
||||||
// Loads common config of DRAMs
|
// 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
|
// Load specific config
|
||||||
static void loadDDR3(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadDDR3(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadDDR4(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadDDR4(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadLPDDR4(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadLPDDR4(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadWideIO(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadWideIO(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadWideIO2(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadWideIO2(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadHBM2(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadHBM2(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadGDDR5(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadGDDR5(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadGDDR5X(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadGDDR5X(Configuration &config, nlohmann::json &memspec);
|
||||||
static void loadGDDR6(Configuration &config, nlohmann::json::object_t *memspec);
|
static void loadGDDR6(Configuration &config, nlohmann::json &memspec);
|
||||||
|
|
||||||
static unsigned int uIntParameter(nlohmann::json obj, std::string name);
|
static unsigned int parseUint(nlohmann::json &obj, std::string name);
|
||||||
static double doubleParameter(nlohmann::json obj, std::string name);
|
static double parseUdouble(nlohmann::json &obj, std::string name);
|
||||||
static std::string stringParameter(nlohmann::json obj, std::string name);
|
static std::string parseString(nlohmann::json &obj, std::string name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
struct TemperatureSimConfig
|
struct TemperatureSimConfig
|
||||||
{
|
{
|
||||||
// Temperature Scale
|
// Temperature Scale
|
||||||
std::string TemperatureScale;
|
std::string temperatureScale;
|
||||||
std::string pathToResources;
|
std::string pathToResources;
|
||||||
|
|
||||||
void setPathToResources(std::string path)
|
void setPathToResources(std::string path)
|
||||||
@@ -56,17 +56,17 @@ struct TemperatureSimConfig
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Static Temperature Simulation parameters
|
// Static Temperature Simulation parameters
|
||||||
int StaticTemperatureDefaultValue;
|
int staticTemperatureDefaultValue;
|
||||||
|
|
||||||
// Thermal Simulation parameters
|
// Thermal Simulation parameters
|
||||||
double ThermalSimPeriod;
|
double thermalSimPeriod;
|
||||||
enum sc_time_unit ThermalSimUnit;
|
enum sc_time_unit thermalSimUnit;
|
||||||
std::string IceServerIp;
|
std::string iceServerIp;
|
||||||
unsigned int IceServerPort;
|
unsigned int iceServerPort;
|
||||||
unsigned int SimPeriodAdjustFactor;
|
unsigned int simPeriodAdjustFactor;
|
||||||
unsigned int NPowStableCyclesToIncreasePeriod;
|
unsigned int nPowStableCyclesToIncreasePeriod;
|
||||||
bool GenerateTemperatureMap;
|
bool generateTemperatureMap;
|
||||||
bool GeneratePowerMap;
|
bool generatePowerMap;
|
||||||
|
|
||||||
// Power related information
|
// Power related information
|
||||||
std::string powerInfoFile;
|
std::string powerInfoFile;
|
||||||
@@ -78,51 +78,54 @@ struct TemperatureSimConfig
|
|||||||
PRINTDEBUGMESSAGE("TemperatureSimConfig", "Power Info File: " + powerInfoFile);
|
PRINTDEBUGMESSAGE("TemperatureSimConfig", "Power Info File: " + powerInfoFile);
|
||||||
|
|
||||||
powerInfoFile = pathToResources
|
powerInfoFile = pathToResources
|
||||||
+ "/configs/thermalsim/"
|
+ "/configs/thermalsim/"
|
||||||
+ powerInfoFile;
|
+ powerInfoFile;
|
||||||
|
|
||||||
// Load the JSON file into memory and parse it
|
// Load the JSON file into memory and parse it
|
||||||
nlohmann::json powInfoElem = parseJSON(powerInfoFile);
|
nlohmann::json powInfoElem = parseJSON(powerInfoFile);
|
||||||
|
|
||||||
if (powInfoElem["powerInfo"].empty()){
|
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()
|
|
||||||
{
|
{
|
||||||
int i __attribute__((unused)) = 0;
|
// Invalid file
|
||||||
for (auto e __attribute__((unused)) : powerInitialValues) {
|
std::string errormsg = "Invalid Power Info File " + powerInfoFile;
|
||||||
PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerInitialValues["
|
PRINTDEBUGMESSAGE("TemperatureSimConfig", errormsg);
|
||||||
+ std::to_string(i++) + "]: " + std::to_string(e));
|
SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str());
|
||||||
}
|
}
|
||||||
i = 0;
|
else
|
||||||
for (auto e __attribute__((unused)) : powerThresholds) {
|
{
|
||||||
PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerThreshold["
|
for (auto it : powInfoElem["powerInfo"].items())
|
||||||
+ std::to_string(i++) + "]: " + std::to_string(e));
|
{
|
||||||
|
// 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
|
#endif // TEMPERATURESIMCONFIG_H
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "DRAMSys.h"
|
#include "DRAMSys.h"
|
||||||
#include "Setup.h"
|
|
||||||
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
|
#include "../common/third_party/nlohmann/single_include/nlohmann/json.hpp"
|
||||||
#include "../common/TlmRecorder.h"
|
#include "../common/TlmRecorder.h"
|
||||||
#include "../common/DebugManager.h"
|
#include "../common/DebugManager.h"
|
||||||
|
|||||||
@@ -59,18 +59,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SC_CTOR(TemperatureController) {
|
SC_CTOR(TemperatureController) {
|
||||||
temperatureScale = Configuration::getInstance().temperatureSim.TemperatureScale;
|
temperatureScale = Configuration::getInstance().temperatureSim.temperatureScale;
|
||||||
|
|
||||||
dynamicTempSimEnabled = Configuration::getInstance().thermalSimulation;
|
dynamicTempSimEnabled = Configuration::getInstance().thermalSimulation;
|
||||||
|
|
||||||
staticTemperature =
|
staticTemperature =
|
||||||
Configuration::getInstance().temperatureSim.StaticTemperatureDefaultValue;
|
Configuration::getInstance().temperatureSim.staticTemperatureDefaultValue;
|
||||||
|
|
||||||
if (dynamicTempSimEnabled == true) {
|
if (dynamicTempSimEnabled == true) {
|
||||||
#ifdef THERMALSIM
|
#ifdef THERMALSIM
|
||||||
// Connect to the server
|
// Connect to the server
|
||||||
std::string ip = Configuration::getInstance().temperatureSim.IceServerIp;
|
std::string ip = Configuration::getInstance().temperatureSim.iceServerIp;
|
||||||
unsigned int port = Configuration::getInstance().temperatureSim.IceServerPort;
|
unsigned int port = Configuration::getInstance().temperatureSim.iceServerPort;
|
||||||
thermalSimulation = new IceWrapper(ip, port);
|
thermalSimulation = new IceWrapper(ip, port);
|
||||||
PRINTDEBUGMESSAGE(name(), "Dynamic temperature simulation. Server @ "
|
PRINTDEBUGMESSAGE(name(), "Dynamic temperature simulation. Server @ "
|
||||||
+ ip + ":" + std::to_string(port));
|
+ ip + ":" + std::to_string(port));
|
||||||
@@ -87,21 +87,21 @@ public:
|
|||||||
powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds;
|
powerThresholds = Configuration::getInstance().temperatureSim.powerThresholds;
|
||||||
decreaseSimPeriod = false;
|
decreaseSimPeriod = false;
|
||||||
periodAdjustFactor =
|
periodAdjustFactor =
|
||||||
Configuration::getInstance().temperatureSim.SimPeriodAdjustFactor;
|
Configuration::getInstance().temperatureSim.simPeriodAdjustFactor;
|
||||||
nPowStableCyclesToIncreasePeriod =
|
nPowStableCyclesToIncreasePeriod =
|
||||||
Configuration::getInstance().temperatureSim.NPowStableCyclesToIncreasePeriod;
|
Configuration::getInstance().temperatureSim.nPowStableCyclesToIncreasePeriod;
|
||||||
cyclesSinceLastPeriodAdjust = 0;
|
cyclesSinceLastPeriodAdjust = 0;
|
||||||
|
|
||||||
// Get the target period for the thermal simulation from config.
|
// Get the target period for the thermal simulation from config.
|
||||||
targetPeriod = Configuration::getInstance().temperatureSim.ThermalSimPeriod;
|
targetPeriod = Configuration::getInstance().temperatureSim.thermalSimPeriod;
|
||||||
period = targetPeriod;
|
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";
|
temperatureMapFile = "temperature_map";
|
||||||
std::system("rm -f temperature_map*");
|
std::system("rm -f temperature_map*");
|
||||||
|
|
||||||
genPowerMap = Configuration::getInstance().temperatureSim.GeneratePowerMap;
|
genPowerMap = Configuration::getInstance().temperatureSim.generatePowerMap;
|
||||||
powerMapFile = "power_map";
|
powerMapFile = "power_map";
|
||||||
std::system("rm -f power_map*");
|
std::system("rm -f power_map*");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user