Merge branch 'feat/simulation_time' into 'develop'

Introduce SimulationTime config

Closes #62

See merge request ems/astdm/modeling.dram/dram.sys.5!91
This commit is contained in:
Lukas Steiner
2024-12-17 14:52:22 +00:00
8 changed files with 25 additions and 9 deletions

View File

@@ -52,7 +52,7 @@ static void ddr3Simulation(benchmark::State& state)
DRAMSys::Config::Configuration configuration = DRAMSys::Config::from_path(configFile.c_str());
Simulator simulator(std::move(configuration), std::move(resourceDirectory));
Simulator::run();
simulator.run();
}
std::cout.rdbuf(rdbuf);

View File

@@ -157,6 +157,7 @@ The content of [ddr3.json](simconfig/example.json) is presented below as an exam
{
"simconfig": {
"SimulationName": "example",
"SimulationTime": 1e-3,
"Debug": false,
"DatabaseRecording": true,
"PowerAnalysis": false,
@@ -173,6 +174,9 @@ The content of [ddr3.json](simconfig/example.json) is presented below as an exam
- *SimulationName* (string)
- Give the name of the simulation for distinguishing from other simulations.
- *SimulationTime* (double)
- Time in seconds after which the simulation is forcibly stopped. Useful for generating multiple simulations over the exact same timeframe.
- Default: unlimited
- *Debug* (boolean)
- true: enables debug output on console (only supported by a debug build)
- false: disables debug output

View File

@@ -72,6 +72,7 @@ struct SimConfig
std::optional<bool> ThermalSimulation;
std::optional<bool> UseMalloc;
std::optional<unsigned int> WindowSize;
std::optional<double> SimulationTime;
};
NLOHMANN_JSONIFY_ALL_THINGS(SimConfig,
@@ -86,7 +87,8 @@ NLOHMANN_JSONIFY_ALL_THINGS(SimConfig,
StoreMode,
ThermalSimulation,
UseMalloc,
WindowSize)
WindowSize,
SimulationTime)
} // namespace DRAMSys::Config

View File

@@ -57,7 +57,7 @@ int sc_main(int argc, char** argv)
DRAMSys::Config::from_path(baseConfig.c_str(), resourceDirectory.c_str());
Simulator simulator(std::move(configuration), std::move(resourceDirectory));
Simulator::run();
simulator.run();
return 0;
}

View File

@@ -156,7 +156,15 @@ void Simulator::run()
auto start = std::chrono::high_resolution_clock::now();
// Start the SystemC simulation
sc_core::sc_start();
if (configuration.simconfig.SimulationTime.has_value())
{
sc_core::sc_start(
sc_core::sc_time(configuration.simconfig.SimulationTime.value(), sc_core::SC_SEC));
}
else
{
sc_core::sc_start();
}
if (!sc_core::sc_end_of_simulation_invoked())
{

View File

@@ -49,7 +49,7 @@ public:
Simulator(DRAMSys::Config::Configuration configuration,
std::filesystem::path resourceDirectory);
static void run();
void run();
private:
std::unique_ptr<Initiator> instantiateInitiator(const DRAMSys::Config::Initiator& initiator);

View File

@@ -151,7 +151,8 @@
"StoreMode": "NoStorage",
"ThermalSimulation": false,
"UseMalloc": false,
"WindowSize": 1000
"WindowSize": 1000,
"SimulationTime": 1e-3
},
"simulationid": "std::string_simulationId",
"tracesetup": [

View File

@@ -39,7 +39,6 @@
#include <fstream>
#include <gtest/gtest.h>
#include <iostream>
#include <unordered_map>
using namespace DRAMSys::Config;
@@ -115,7 +114,8 @@ protected:
DRAMSys::Config::StoreModeType::NoStorage,
false,
false,
1000};
1000,
1e-3};
DRAMSys::Config::MemSpec memSpec;
@@ -328,7 +328,8 @@ TEST_F(ConfigurationTest, SimConfig)
"StoreMode": "NoStorage",
"ThermalSimulation": false,
"UseMalloc": false,
"WindowSize": 1000
"WindowSize": 1000,
"SimulationTime": 1e-3
}
}
)";