Introduce SimulationTime config

Use SimulationTime to forcefully stop simulation at a specified point in
time.
This commit is contained in:
2024-12-10 10:03:07 +01:00
parent be1807e9b0
commit 703ee81d7e
7 changed files with 24 additions and 8 deletions

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 at which the simulation is forcefully 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
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
}
}
)";