Make configuration library backwards compatible
It's now possible to either directly insert the configuration objects into the main config json (new format) or just to enter the json file names to the configurations (old format).
This commit is contained in:
@@ -322,4 +322,5 @@ endif()
|
||||
target_link_libraries(DRAMSysLibrary
|
||||
PUBLIC ${SYSTEMC_LIBRARY}
|
||||
PRIVATE DRAMPower
|
||||
PRIVATE DRAMSysConfiguration
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const AddressMapping &m)
|
||||
@@ -51,26 +51,32 @@ void to_json(json &j, const AddressMapping &m)
|
||||
{"BANK_BIT", m.bankBits},
|
||||
{"ROW_BIT", m.rowBits}};
|
||||
|
||||
Util::from_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
Util::from_optional("BYTE_BIT", congen, m.byteBits);
|
||||
Util::from_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
Util::from_optional("XOR", congen, m.xorBits);
|
||||
from_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
from_optional("BYTE_BIT", congen, m.byteBits);
|
||||
from_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
from_optional("XOR", congen, m.xorBits);
|
||||
|
||||
j["CONGEN"] = congen;
|
||||
}
|
||||
|
||||
void from_json(const json &j, AddressMapping &m)
|
||||
{
|
||||
json congen = j.at("CONGEN");
|
||||
json j_addressmapping = get_config_json(j, addressMappingPath, "CONGEN");
|
||||
|
||||
json congen;
|
||||
if (j_addressmapping["CONGEN"].is_null())
|
||||
congen = j_addressmapping;
|
||||
else
|
||||
congen = j_addressmapping["CONGEN"];
|
||||
|
||||
congen.at("COLUMN_BIT").get_to(m.coloumnBits);
|
||||
congen.at("BANK_BIT").get_to(m.bankBits);
|
||||
congen.at("ROW_BIT").get_to(m.rowBits);
|
||||
|
||||
Util::get_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
Util::get_optional("BYTE_BIT", congen, m.byteBits);
|
||||
Util::get_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
Util::get_optional("XOR", congen, m.xorBits);
|
||||
get_optional("CHANNEL_BIT", congen, m.channelBits);
|
||||
get_optional("BYTE_BIT", congen, m.byteBits);
|
||||
get_optional("BANKGROUP_BIT", congen, m.bankGroupBits);
|
||||
get_optional("XOR", congen, m.xorBits);
|
||||
}
|
||||
|
||||
void to_json(json &j, const XorPair &x)
|
||||
|
||||
@@ -39,10 +39,12 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
const std::string addressMappingPath = "configs/amconfigs";
|
||||
|
||||
struct XorPair
|
||||
{
|
||||
unsigned int first;
|
||||
|
||||
@@ -51,7 +51,10 @@ add_library(DRAMSysConfiguration STATIC
|
||||
memspec/MemArchitectureSpec.cpp
|
||||
memspec/MemPowerSpec.cpp
|
||||
memspec/MemTimingSpec.cpp
|
||||
util.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(DRAMSysConfiguration PRIVATE DRAMSysResourceDirectory="${CMAKE_SOURCE_DIR}/library/resources")
|
||||
|
||||
target_link_libraries(DRAMSysConfiguration PRIVATE nlohmann_json::nlohmann_json)
|
||||
target_include_directories(DRAMSysConfiguration PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
#include "Configuration.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const Configuration &c)
|
||||
@@ -49,8 +49,8 @@ void to_json(json &j, const Configuration &c)
|
||||
{"simulationid", c.simulationId},
|
||||
{"simconfig", c.simConfig}};
|
||||
|
||||
Util::from_optional("thermalconfig", j, c.thermalConfig);
|
||||
Util::from_optional("tracesetup", j, c.traceSetup);
|
||||
from_optional("thermalconfig", j, c.thermalConfig);
|
||||
from_optional("tracesetup", j, c.traceSetup);
|
||||
}
|
||||
|
||||
void from_json(const json &j, Configuration &c)
|
||||
@@ -61,8 +61,15 @@ void from_json(const json &j, Configuration &c)
|
||||
j.at("simulationid").get_to(c.simulationId);
|
||||
j.at("simconfig").get_to(c.simConfig);
|
||||
|
||||
Util::get_optional("thermalconfig", j, c.thermalConfig);
|
||||
Util::get_optional("tracesetup", j, c.traceSetup);
|
||||
get_optional("thermalconfig", j, c.thermalConfig);
|
||||
get_optional("tracesetup", j, c.traceSetup);
|
||||
}
|
||||
|
||||
Configuration from_path(const std::string &path)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
json simulation = json::parse(file).at("simulation");
|
||||
return simulation.get<DRAMSysConfiguration::Configuration>();
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
* Consider also switching to std::variant to achieve static polymorphism.
|
||||
*/
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -75,6 +75,8 @@ struct Configuration
|
||||
void to_json(json &j, const Configuration &p);
|
||||
void from_json(const json &j, Configuration &p);
|
||||
|
||||
Configuration from_path(const std::string &path);
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
#endif // CONFIGURATION_H
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "McConfig.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const McConfig &c)
|
||||
@@ -54,25 +54,27 @@ void to_json(json &j, const McConfig &c)
|
||||
{"Arbiter", c.arbiter},
|
||||
{"MaxActiveTransactions", c.maxActiveTransactions}};
|
||||
|
||||
Util::from_optional("RefreshManagment", j, c.refreshManagement);
|
||||
from_optional("RefreshManagment", j, c.refreshManagement);
|
||||
}
|
||||
|
||||
void from_json(const json &j, McConfig &c)
|
||||
{
|
||||
j.at("PagePolicy").get_to(c.pagePolicy);
|
||||
j.at("Scheduler").get_to(c.scheduler);
|
||||
j.at("SchedulerBuffer").get_to(c.schedulerBuffer);
|
||||
j.at("RequestBufferSize").get_to(c.requestBufferSize);
|
||||
j.at("CmdMux").get_to(c.cmdMux);
|
||||
j.at("RespQueue").get_to(c.respQueue);
|
||||
j.at("RefreshPolicy").get_to(c.refreshPolicy);
|
||||
j.at("RefreshMaxPostponed").get_to(c.refreshMaxPostponed);
|
||||
j.at("RefreshMaxPulledin").get_to(c.refreshMaxPulledin);
|
||||
j.at("PowerDownPolicy").get_to(c.powerDownPolicy);
|
||||
j.at("Arbiter").get_to(c.arbiter);
|
||||
j.at("MaxActiveTransactions").get_to(c.maxActiveTransactions);
|
||||
json j_mcconfig = get_config_json(j, mcConfigPath, "mcconfig");
|
||||
|
||||
Util::get_optional("RefreshManagment", j, c.refreshManagement);
|
||||
j_mcconfig.at("PagePolicy").get_to(c.pagePolicy);
|
||||
j_mcconfig.at("Scheduler").get_to(c.scheduler);
|
||||
j_mcconfig.at("SchedulerBuffer").get_to(c.schedulerBuffer);
|
||||
j_mcconfig.at("RequestBufferSize").get_to(c.requestBufferSize);
|
||||
j_mcconfig.at("CmdMux").get_to(c.cmdMux);
|
||||
j_mcconfig.at("RespQueue").get_to(c.respQueue);
|
||||
j_mcconfig.at("RefreshPolicy").get_to(c.refreshPolicy);
|
||||
j_mcconfig.at("RefreshMaxPostponed").get_to(c.refreshMaxPostponed);
|
||||
j_mcconfig.at("RefreshMaxPulledin").get_to(c.refreshMaxPulledin);
|
||||
j_mcconfig.at("PowerDownPolicy").get_to(c.powerDownPolicy);
|
||||
j_mcconfig.at("Arbiter").get_to(c.arbiter);
|
||||
j_mcconfig.at("MaxActiveTransactions").get_to(c.maxActiveTransactions);
|
||||
|
||||
get_optional("RefreshManagment", j_mcconfig, c.refreshManagement);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
@@ -40,10 +40,12 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
const std::string mcConfigPath = "configs/mcconfigs";
|
||||
|
||||
enum class PagePolicy
|
||||
{
|
||||
Open,
|
||||
|
||||
@@ -34,8 +34,9 @@
|
||||
*/
|
||||
|
||||
#include "SimConfig.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const SimConfig &c)
|
||||
@@ -59,21 +60,23 @@ void to_json(json &j, const SimConfig &c)
|
||||
|
||||
void from_json(const json &j, SimConfig &c)
|
||||
{
|
||||
j.at("AddressOffset").get_to(c.addressOffset);
|
||||
j.at("CheckTLM2Protocol").get_to(c.checkTLM2Protocol);
|
||||
j.at("DatabaseRecording").get_to(c.databaseRecording);
|
||||
j.at("Debug").get_to(c.debug);
|
||||
j.at("ECCControllerMode").get_to(c.eccControllerMode);
|
||||
j.at("EnableWindowing").get_to(c.enableWindowing);
|
||||
j.at("ErrorCSVFile").get_to(c.errorCsvFile);
|
||||
j.at("ErrorChipSeed").get_to(c.errorChipSeed);
|
||||
j.at("PowerAnalysis").get_to(c.powerAnalysis);
|
||||
j.at("SimulationName").get_to(c.simulationName);
|
||||
j.at("SimulationProgressBar").get_to(c.simulationProgressBar);
|
||||
j.at("StoreMode").get_to(c.storeMode);
|
||||
j.at("ThermalSimulation").get_to(c.thermalSimulation);
|
||||
j.at("UseMalloc").get_to(c.useMalloc);
|
||||
j.at("WindowSize").get_to(c.windowSize);
|
||||
json j_simconfig = get_config_json(j, simConfigPath, "simconfig");
|
||||
|
||||
j_simconfig.at("AddressOffset").get_to(c.addressOffset);
|
||||
j_simconfig.at("CheckTLM2Protocol").get_to(c.checkTLM2Protocol);
|
||||
j_simconfig.at("DatabaseRecording").get_to(c.databaseRecording);
|
||||
j_simconfig.at("Debug").get_to(c.debug);
|
||||
j_simconfig.at("ECCControllerMode").get_to(c.eccControllerMode);
|
||||
j_simconfig.at("EnableWindowing").get_to(c.enableWindowing);
|
||||
j_simconfig.at("ErrorCSVFile").get_to(c.errorCsvFile);
|
||||
j_simconfig.at("ErrorChipSeed").get_to(c.errorChipSeed);
|
||||
j_simconfig.at("PowerAnalysis").get_to(c.powerAnalysis);
|
||||
j_simconfig.at("SimulationName").get_to(c.simulationName);
|
||||
j_simconfig.at("SimulationProgressBar").get_to(c.simulationProgressBar);
|
||||
j_simconfig.at("StoreMode").get_to(c.storeMode);
|
||||
j_simconfig.at("ThermalSimulation").get_to(c.thermalSimulation);
|
||||
j_simconfig.at("UseMalloc").get_to(c.useMalloc);
|
||||
j_simconfig.at("WindowSize").get_to(c.windowSize);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
const std::string simConfigPath = "configs/simulator";
|
||||
|
||||
enum class ECCControllerMode
|
||||
{
|
||||
Disabled,
|
||||
|
||||
@@ -34,8 +34,9 @@
|
||||
*/
|
||||
|
||||
#include "ThermalConfig.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const ThermalConfig &c)
|
||||
@@ -55,17 +56,19 @@ void to_json(json &j, const ThermalConfig &c)
|
||||
|
||||
void from_json(const json &j, ThermalConfig &c)
|
||||
{
|
||||
j.at("TemperatureScale").get_to(c.temperatureScale);
|
||||
j.at("StaticTemperatureDefaultValue").get_to(c.staticTemperatureDefaultValue);
|
||||
j.at("ThermalSimPeriod").get_to(c.thermalSimPeriod);
|
||||
j.at("ThermalSimUnit").get_to(c.thermalSimUnit);
|
||||
j.at("PowerInfoFile").get_to(c.powerInfo);
|
||||
j.at("IceServerIp").get_to(c.iceServerIp);
|
||||
j.at("IceServerPort").get_to(c.iceServerPort);
|
||||
j.at("SimPeriodAdjustFactor").get_to(c.simPeriodAdjustFactor);
|
||||
j.at("NPowStableCyclesToIncreasePeriod").get_to(c.nPowStableCyclesToIncreasePeriod);
|
||||
j.at("GenerateTemperatureMap").get_to(c.generateTemperatureMap);
|
||||
j.at("GeneratePowerMap").get_to(c.generatePowerMap);
|
||||
json j_thermalsim = get_config_json(j, thermalConfigPath, "thermalsimconfig");
|
||||
|
||||
j_thermalsim.at("TemperatureScale").get_to(c.temperatureScale);
|
||||
j_thermalsim.at("StaticTemperatureDefaultValue").get_to(c.staticTemperatureDefaultValue);
|
||||
j_thermalsim.at("ThermalSimPeriod").get_to(c.thermalSimPeriod);
|
||||
j_thermalsim.at("ThermalSimUnit").get_to(c.thermalSimUnit);
|
||||
j_thermalsim.at("PowerInfoFile").get_to(c.powerInfo);
|
||||
j_thermalsim.at("IceServerIp").get_to(c.iceServerIp);
|
||||
j_thermalsim.at("IceServerPort").get_to(c.iceServerPort);
|
||||
j_thermalsim.at("SimPeriodAdjustFactor").get_to(c.simPeriodAdjustFactor);
|
||||
j_thermalsim.at("NPowStableCyclesToIncreasePeriod").get_to(c.nPowStableCyclesToIncreasePeriod);
|
||||
j_thermalsim.at("GenerateTemperatureMap").get_to(c.generateTemperatureMap);
|
||||
j_thermalsim.at("GeneratePowerMap").get_to(c.generatePowerMap);
|
||||
}
|
||||
|
||||
void to_json(json &j, const DramDieChannel &c)
|
||||
@@ -89,10 +92,12 @@ void to_json(json &j, const PowerInfo &c)
|
||||
|
||||
void from_json(const json &j, PowerInfo &c)
|
||||
{
|
||||
j.at("dram_die_channel0").get_to(c.channel0);
|
||||
j.at("dram_die_channel1").get_to(c.channel1);
|
||||
j.at("dram_die_channel2").get_to(c.channel2);
|
||||
j.at("dram_die_channel3").get_to(c.channel3);
|
||||
json j_powerinfo = get_config_json(j, thermalConfigPath, "powerInfo");
|
||||
|
||||
j_powerinfo.at("dram_die_channel0").get_to(c.channel0);
|
||||
j_powerinfo.at("dram_die_channel1").get_to(c.channel1);
|
||||
j_powerinfo.at("dram_die_channel2").get_to(c.channel2);
|
||||
j_powerinfo.at("dram_die_channel3").get_to(c.channel3);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
@@ -38,10 +38,12 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
const std::string thermalConfigPath = "configs/thermalsim";
|
||||
|
||||
enum class TemperatureScale
|
||||
{
|
||||
Celsius,
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "TraceSetup.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
TrafficInitiator::~TrafficInitiator()
|
||||
@@ -62,11 +62,11 @@ void to_json(json &j, const TraceSetup &c)
|
||||
inititator_j["rwRatio"] = generator->rwRatio;
|
||||
inititator_j["addressDistribution"] = generator->addressDistribution;
|
||||
|
||||
Util::from_optional("seed", inititator_j, generator->seed);
|
||||
Util::from_optional("maxPendingReadRequests", inititator_j, generator->maxPendingReadRequests);
|
||||
Util::from_optional("maxPendingWriteRequests", inititator_j, generator->maxPendingWriteRequests);
|
||||
Util::from_optional("minAddress", inititator_j, generator->minAddress);
|
||||
Util::from_optional("maxAddress", inititator_j, generator->maxAddress);
|
||||
from_optional("seed", inititator_j, generator->seed);
|
||||
from_optional("maxPendingReadRequests", inititator_j, generator->maxPendingReadRequests);
|
||||
from_optional("maxPendingWriteRequests", inititator_j, generator->maxPendingWriteRequests);
|
||||
from_optional("minAddress", inititator_j, generator->minAddress);
|
||||
from_optional("maxAddress", inititator_j, generator->maxAddress);
|
||||
}
|
||||
else if (const auto hammer = dynamic_cast<TraceHammer *>(initiator.get()))
|
||||
{
|
||||
@@ -103,11 +103,11 @@ void from_json(const json &j, TraceSetup &c)
|
||||
initiator_j.at("rwRatio").get_to(generator->rwRatio);
|
||||
initiator_j.at("addressDistribution").get_to(generator->addressDistribution);
|
||||
|
||||
Util::get_optional("seed", initiator_j, generator->seed);
|
||||
Util::get_optional("maxPendingReadRequests", initiator_j, generator->maxPendingReadRequests);
|
||||
Util::get_optional("maxPendingWriteRequests", initiator_j, generator->maxPendingWriteRequests);
|
||||
Util::get_optional("minAddress", initiator_j, generator->minAddress);
|
||||
Util::get_optional("maxAddress", initiator_j, generator->maxAddress);
|
||||
get_optional("seed", initiator_j, generator->seed);
|
||||
get_optional("maxPendingReadRequests", initiator_j, generator->maxPendingReadRequests);
|
||||
get_optional("maxPendingWriteRequests", initiator_j, generator->maxPendingWriteRequests);
|
||||
get_optional("minAddress", initiator_j, generator->minAddress);
|
||||
get_optional("maxAddress", initiator_j, generator->maxAddress);
|
||||
|
||||
initiator = std::unique_ptr<TraceGenerator>(generator);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "MemArchitectureSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemArchitectureSpec &c)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "MemPowerSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemPowerSpec &c)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "MemSpec.h"
|
||||
#include "util.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemSpec &c)
|
||||
@@ -46,17 +46,19 @@ void to_json(json &j, const MemSpec &c)
|
||||
{"memoryType", c.memoryType},
|
||||
{"memtimingspec", c.memTimingSpec}};
|
||||
|
||||
Util::from_optional("mempowerspec", j, c.memPowerSpec);
|
||||
from_optional("mempowerspec", j, c.memPowerSpec);
|
||||
}
|
||||
|
||||
void from_json(const json &j, MemSpec &c)
|
||||
{
|
||||
j.at("memarchitecturespec").get_to(c.memArchitectureSpec);
|
||||
j.at("memoryId").get_to(c.memoryId);
|
||||
j.at("memoryType").get_to(c.memoryType);
|
||||
j.at("memtimingspec").get_to(c.memTimingSpec);
|
||||
json j_memspecs = get_config_json(j, memSpecPath, "memspec");
|
||||
|
||||
Util::get_optional("mempowerspec", j, c.memPowerSpec);
|
||||
j_memspecs.at("memarchitecturespec").get_to(c.memArchitectureSpec);
|
||||
j_memspecs.at("memoryId").get_to(c.memoryId);
|
||||
j_memspecs.at("memoryType").get_to(c.memoryType);
|
||||
j_memspecs.at("memtimingspec").get_to(c.memTimingSpec);
|
||||
|
||||
get_optional("mempowerspec", j, c.memPowerSpec);
|
||||
}
|
||||
|
||||
} // namespace Configuration
|
||||
|
||||
@@ -42,10 +42,12 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
const std::string memSpecPath = "configs/memspecs";
|
||||
|
||||
struct MemSpec
|
||||
{
|
||||
MemArchitectureSpec memArchitectureSpec;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
#include "MemTimingSpec.h"
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
void to_json(json &j, const MemTimingSpec &c)
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace Configuration
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
@@ -4,126 +4,105 @@
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
Configuration::AddressMapping getAddressMapping()
|
||||
DRAMSysConfiguration::AddressMapping getAddressMapping()
|
||||
{
|
||||
// Configuration::ConGen *mycongen = new Configuration::ConGen;
|
||||
// mycongen->byteBits = {{0, 1}, true};
|
||||
// mycongen->bankBits = {16};
|
||||
// mycongen->bankGroupBits = {{13, 14, 15}, true};
|
||||
// mycongen->coloumnBits = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
|
||||
// mycongen->channelBits = {{33}, true};
|
||||
// mycongen->rowBits = {17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32};
|
||||
// return std::unique_ptr<Configuration::AddressMapping>(mycongen);
|
||||
|
||||
return Configuration::AddressMapping{{{0, 1}, true},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
|
||||
{16},
|
||||
{{13, 14, 15}, true},
|
||||
{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||
{{33}, true},
|
||||
{{}, false}};
|
||||
return DRAMSysConfiguration::AddressMapping{{{0, 1}, true},
|
||||
{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12},
|
||||
{16},
|
||||
{{13, 14, 15}, true},
|
||||
{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32},
|
||||
{{33}, true},
|
||||
{{}, false}};
|
||||
}
|
||||
|
||||
Configuration::McConfig getMcConfig()
|
||||
DRAMSysConfiguration::McConfig getMcConfig()
|
||||
{
|
||||
return Configuration::McConfig{Configuration::PagePolicy::Open,
|
||||
Configuration::Scheduler::FrFcfs,
|
||||
Configuration::SchedulerBuffer::Bankwise,
|
||||
8,
|
||||
Configuration::CmdMux::Oldest,
|
||||
Configuration::RespQueue::Fifo,
|
||||
Configuration::RefreshPolicy::AllBank,
|
||||
0,
|
||||
0,
|
||||
Configuration::PowerDownPolicy::NoPowerDown,
|
||||
Configuration::Arbiter::Simple,
|
||||
128,
|
||||
std::pair<bool, bool>{false, true}};
|
||||
return DRAMSysConfiguration::McConfig{DRAMSysConfiguration::PagePolicy::Open,
|
||||
DRAMSysConfiguration::Scheduler::FrFcfs,
|
||||
DRAMSysConfiguration::SchedulerBuffer::Bankwise,
|
||||
8,
|
||||
DRAMSysConfiguration::CmdMux::Oldest,
|
||||
DRAMSysConfiguration::RespQueue::Fifo,
|
||||
DRAMSysConfiguration::RefreshPolicy::AllBank,
|
||||
0,
|
||||
0,
|
||||
DRAMSysConfiguration::PowerDownPolicy::NoPowerDown,
|
||||
DRAMSysConfiguration::Arbiter::Simple,
|
||||
128,
|
||||
std::pair<bool, bool>{false, true}};
|
||||
}
|
||||
|
||||
Configuration::SimConfig getSimConfig()
|
||||
DRAMSysConfiguration::SimConfig getSimConfig()
|
||||
{
|
||||
return Configuration::SimConfig {
|
||||
0,
|
||||
false,
|
||||
return DRAMSysConfiguration::SimConfig{
|
||||
0, false, true, false, DRAMSysConfiguration::ECCControllerMode::Disabled, false, "error.csv",
|
||||
42, false, "ddr5", true, DRAMSysConfiguration::StoreMode::NoStorage, false, false,
|
||||
1000};
|
||||
}
|
||||
|
||||
DRAMSysConfiguration::ThermalConfig getThermalConfig()
|
||||
{
|
||||
return DRAMSysConfiguration::ThermalConfig{
|
||||
DRAMSysConfiguration::TemperatureScale::Celsius,
|
||||
89,
|
||||
100,
|
||||
DRAMSysConfiguration::ThermalSimUnit::Microseconds,
|
||||
DRAMSysConfiguration::PowerInfo{{0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}},
|
||||
"127.0.0.1",
|
||||
118800,
|
||||
10,
|
||||
5,
|
||||
true,
|
||||
false,
|
||||
Configuration::ECCControllerMode::Disabled,
|
||||
false,
|
||||
"error.csv",
|
||||
42,
|
||||
false,
|
||||
"ddr5",
|
||||
true,
|
||||
Configuration::StoreMode::NoStorage,
|
||||
false,
|
||||
false,
|
||||
1000
|
||||
};
|
||||
true};
|
||||
}
|
||||
|
||||
Configuration::ThermalConfig getThermalConfig()
|
||||
std::unique_ptr<DRAMSysConfiguration::TracePlayer> getTracePlayer()
|
||||
{
|
||||
return Configuration::ThermalConfig{Configuration::TemperatureScale::Celsius,
|
||||
89,
|
||||
100,
|
||||
Configuration::ThermalSimUnit::Microseconds,
|
||||
Configuration::PowerInfo{{0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}, {0.0, 1.0}},
|
||||
"127.0.0.1",
|
||||
118800,
|
||||
10,
|
||||
5,
|
||||
true,
|
||||
true};
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TracePlayer> getTracePlayer()
|
||||
{
|
||||
Configuration::TracePlayer *player = new Configuration::TracePlayer;
|
||||
DRAMSysConfiguration::TracePlayer *player = new DRAMSysConfiguration::TracePlayer;
|
||||
|
||||
player->clkMhz = 100;
|
||||
player->name = "mytrace.stl";
|
||||
|
||||
return std::unique_ptr<Configuration::TracePlayer>(player);
|
||||
return std::unique_ptr<DRAMSysConfiguration::TracePlayer>(player);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceGenerator> getTraceGeneratorRandom()
|
||||
std::unique_ptr<DRAMSysConfiguration::TraceGenerator> getTraceGeneratorRandom()
|
||||
{
|
||||
Configuration::TraceGenerator *gen = new Configuration::TraceGenerator;
|
||||
DRAMSysConfiguration::TraceGenerator *gen = new DRAMSysConfiguration::TraceGenerator;
|
||||
|
||||
gen->clkMhz = 100;
|
||||
gen->name = "MyTestGen";
|
||||
|
||||
gen->addressDistribution = Configuration::AddressDistribution::Random;
|
||||
gen->addressDistribution = DRAMSysConfiguration::AddressDistribution::Random;
|
||||
gen->maxAddress = {1000, true};
|
||||
gen->maxPendingReadRequests = {8, true};
|
||||
gen->rwRatio = 0.5;
|
||||
gen->seed = {1337, true};
|
||||
gen->numRequests = 1000;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceGenerator>(gen);
|
||||
return std::unique_ptr<DRAMSysConfiguration::TraceGenerator>(gen);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceGenerator> getTraceGeneratorSequential()
|
||||
std::unique_ptr<DRAMSysConfiguration::TraceGenerator> getTraceGeneratorSequential()
|
||||
{
|
||||
Configuration::TraceGenerator *gen = new Configuration::TraceGenerator;
|
||||
DRAMSysConfiguration::TraceGenerator *gen = new DRAMSysConfiguration::TraceGenerator;
|
||||
|
||||
gen->clkMhz = 100;
|
||||
gen->name = "MyTestGen";
|
||||
|
||||
gen->addressDistribution = Configuration::AddressDistribution::Sequential;
|
||||
gen->addressDistribution = DRAMSysConfiguration::AddressDistribution::Sequential;
|
||||
gen->addressIncrement = {64, true};
|
||||
gen->maxAddress = {1000, true};
|
||||
gen->maxPendingReadRequests = {8, true};
|
||||
gen->rwRatio = 0.5;
|
||||
gen->numRequests = 1000;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceGenerator>(gen);
|
||||
return std::unique_ptr<DRAMSysConfiguration::TraceGenerator>(gen);
|
||||
}
|
||||
|
||||
std::unique_ptr<Configuration::TraceHammer> getTraceHammer()
|
||||
std::unique_ptr<DRAMSysConfiguration::TraceHammer> getTraceHammer()
|
||||
{
|
||||
Configuration::TraceHammer *hammer = new Configuration::TraceHammer;
|
||||
DRAMSysConfiguration::TraceHammer *hammer = new DRAMSysConfiguration::TraceHammer;
|
||||
|
||||
hammer->clkMhz = 100;
|
||||
hammer->name = "MyTestHammer";
|
||||
@@ -131,23 +110,23 @@ std::unique_ptr<Configuration::TraceHammer> getTraceHammer()
|
||||
hammer->numRequests = 4000;
|
||||
hammer->rowIncrement = 2097152;
|
||||
|
||||
return std::unique_ptr<Configuration::TraceHammer>(hammer);
|
||||
return std::unique_ptr<DRAMSysConfiguration::TraceHammer>(hammer);
|
||||
}
|
||||
|
||||
Configuration::TraceSetup getTraceSetup()
|
||||
DRAMSysConfiguration::TraceSetup getTraceSetup()
|
||||
{
|
||||
std::unordered_set<std::unique_ptr<Configuration::TrafficInitiator>> initiators;
|
||||
std::unordered_set<std::unique_ptr<DRAMSysConfiguration::TrafficInitiator>> initiators;
|
||||
initiators.emplace(getTracePlayer());
|
||||
initiators.emplace(getTraceGeneratorRandom());
|
||||
initiators.emplace(getTraceGeneratorSequential());
|
||||
initiators.emplace(getTraceHammer());
|
||||
|
||||
return Configuration::TraceSetup{std::move(initiators)};
|
||||
return DRAMSysConfiguration::TraceSetup{std::move(initiators)};
|
||||
}
|
||||
|
||||
Configuration::Configuration getConfig(const Configuration::MemSpec &memSpec)
|
||||
DRAMSysConfiguration::Configuration getConfig(const DRAMSysConfiguration::MemSpec &memSpec)
|
||||
{
|
||||
return Configuration::Configuration{
|
||||
return DRAMSysConfiguration::Configuration{
|
||||
getAddressMapping(),
|
||||
getMcConfig(),
|
||||
memSpec,
|
||||
@@ -161,10 +140,7 @@ Configuration::Configuration getConfig(const Configuration::MemSpec &memSpec)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ifstream file("ddr5.json");
|
||||
json ddr5_j = json::parse(file, nullptr, false);
|
||||
json config = ddr5_j.at("simulation");
|
||||
Configuration::Configuration conf = config.get<Configuration::Configuration>();
|
||||
DRAMSysConfiguration::Configuration conf = DRAMSysConfiguration::from_path("ddr5.json");
|
||||
std::ofstream fileout("myjson.json");
|
||||
json j_my;
|
||||
j_my["simulation"] = getConfig(conf.memSpec); // just copy memspec over
|
||||
@@ -173,9 +149,18 @@ int main()
|
||||
std::ifstream file2("hbm2.json");
|
||||
json hbm2_j = json::parse(file2, nullptr, false);
|
||||
json hbm2_config = hbm2_j.at("simulation");
|
||||
Configuration::Configuration hbm2conf = hbm2_config.get<Configuration::Configuration>();
|
||||
DRAMSysConfiguration::Configuration hbm2conf = hbm2_config.get<DRAMSysConfiguration::Configuration>();
|
||||
std::ofstream filehbm2("myhbm2.json");
|
||||
json j_myhbm2;
|
||||
j_myhbm2["simulation"] = hbm2conf;
|
||||
filehbm2 << j_myhbm2.dump(4);
|
||||
|
||||
std::ifstream file3("old_conf.json");
|
||||
json ddr5_old = json::parse(file3, nullptr, false);
|
||||
json ddr5_old_conf = ddr5_old.at("simulation");
|
||||
DRAMSysConfiguration::Configuration ddr5_old_config = ddr5_old_conf.get<DRAMSysConfiguration::Configuration>();
|
||||
std::ofstream fileoldout("old_conf_converted.json");
|
||||
json j_oldconfconv;
|
||||
j_oldconfconv["simulation"] = ddr5_old_config;
|
||||
fileoldout << j_oldconfconv.dump(4);
|
||||
}
|
||||
|
||||
60
DRAMSys/library/src/common/configuration/util.cpp
Normal file
60
DRAMSys/library/src/common/configuration/util.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Technische Universität 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:
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
|
||||
json get_config_json(const json &j, const std::string &configPath, const std::string &objectName)
|
||||
{
|
||||
if (j.is_object())
|
||||
{
|
||||
return j;
|
||||
}
|
||||
else // j should be a string path to the real json file
|
||||
{
|
||||
std::string jsonFileName;
|
||||
j.get_to(jsonFileName);
|
||||
|
||||
std::ifstream file(std::string(DRAMSysResourceDirectory) + "/" + configPath + "/" + jsonFileName);
|
||||
json j_object = json::parse(file);
|
||||
return j_object.at(objectName);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace DRAMSysConfiguration
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <utility>
|
||||
|
||||
namespace Util
|
||||
namespace DRAMSysConfiguration
|
||||
{
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -70,6 +70,8 @@ void from_optional(const std::string &name, json &j, const std::pair<T, bool> &v
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Util
|
||||
json get_config_json(const json &j, const std::string &configPath, const std::string &objectName);
|
||||
|
||||
} // namespace DRAMSysConfiguration
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user