batch simulation
This commit is contained in:
@@ -17,7 +17,7 @@ using namespace std;
|
||||
|
||||
namespace simulation {
|
||||
|
||||
SimulationManager::SimulationManager(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
|
||||
Simulation::Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
|
||||
std::vector<Device> devices, bool silent) :
|
||||
traceName(traceName)
|
||||
|
||||
@@ -66,7 +66,7 @@ SimulationManager::SimulationManager(sc_module_name name, string pathToResources
|
||||
DebugManager::getInstance().addToWhiteList(whiteList);
|
||||
}
|
||||
|
||||
SimulationManager::~SimulationManager()
|
||||
Simulation::~Simulation()
|
||||
{
|
||||
delete dram;
|
||||
delete arbiter;
|
||||
@@ -75,9 +75,10 @@ SimulationManager::~SimulationManager()
|
||||
delete player2;
|
||||
}
|
||||
|
||||
void SimulationManager::startSimulation()
|
||||
void Simulation::startSimulation()
|
||||
{
|
||||
|
||||
|
||||
clock_t begin = clock();
|
||||
|
||||
DebugManager::getInstance().printDebugMessage(name(), "Starting simulation");
|
||||
@@ -91,7 +92,7 @@ void SimulationManager::startSimulation()
|
||||
"Simulation took " + to_string(elapsed_secs) + " seconds");
|
||||
}
|
||||
|
||||
void SimulationManager::tracePlayerFinishedCallback(string name)
|
||||
void Simulation::tracePlayerFinishedCallback(string name)
|
||||
{
|
||||
|
||||
DebugManager::getInstance().printDebugMessage(this->name(), "Traceplayer " + name + " finshed");
|
||||
@@ -103,7 +104,7 @@ void SimulationManager::tracePlayerFinishedCallback(string name)
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationManager::terminationThread()
|
||||
void Simulation::terminationThread()
|
||||
{
|
||||
wait(terminateSimulation);
|
||||
DebugManager::getInstance().printDebugMessage(this->name(), "Terminating simulation");
|
||||
|
||||
@@ -28,7 +28,7 @@ struct DramSetup
|
||||
|
||||
struct Device
|
||||
{
|
||||
Device():trace(""), burstLength(0){}
|
||||
Device():trace("empty.stl"), burstLength(0){}
|
||||
Device(std::string trace, unsigned int burstLength = 0) : trace(trace), burstLength(burstLength)
|
||||
{
|
||||
}
|
||||
@@ -36,13 +36,13 @@ struct Device
|
||||
unsigned int burstLength;
|
||||
};
|
||||
|
||||
class SimulationManager: public ISimulationManager, public sc_module
|
||||
class Simulation: public ISimulationManager, public sc_module
|
||||
{
|
||||
public:
|
||||
SC_HAS_PROCESS(SimulationManager);
|
||||
SimulationManager(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
|
||||
SC_HAS_PROCESS(Simulation);
|
||||
Simulation(sc_module_name name, string pathToResources, string traceName, DramSetup setup,
|
||||
std::vector<Device> devices, bool silent = false);
|
||||
~SimulationManager();
|
||||
~Simulation();
|
||||
void startSimulation();
|
||||
void tracePlayerFinishedCallback(string name) override;
|
||||
|
||||
|
||||
@@ -11,15 +11,22 @@
|
||||
#include "../core/configuration/Configuration.h"
|
||||
|
||||
#include <systemc.h>
|
||||
#include <sys/wait.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace simulation;
|
||||
|
||||
string resources;
|
||||
|
||||
string pathOfFile(string file)
|
||||
{
|
||||
return file.substr(0, file.find_last_of('/'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void startTraceAnalyzer(string traceName)
|
||||
{
|
||||
string p = getenv("trace");
|
||||
@@ -27,29 +34,66 @@ void startTraceAnalyzer(string traceName)
|
||||
system(run_tpr.c_str());
|
||||
}
|
||||
|
||||
bool runSimulation(string resources, string traceName, DramSetup setup, vector<Device> devices)
|
||||
{
|
||||
int pid = fork();
|
||||
int status = 0;
|
||||
if (pid == 0)
|
||||
{
|
||||
Simulation simulation("sim", resources, traceName, setup, devices);
|
||||
simulation.startSimulation();
|
||||
return true;
|
||||
}
|
||||
waitpid(pid, &status, 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool batchTraces(DramSetup setup, vector<pair<string, string>> tracePairs)
|
||||
{
|
||||
int id =0;
|
||||
for(pair<string, string> pair : tracePairs)
|
||||
{
|
||||
id++;
|
||||
string traceName = "batch" + to_string(id) + ".tdb";
|
||||
if(runSimulation(resources, traceName, setup, { Device(pair.first), Device(pair.second) }))
|
||||
return true;//kill child
|
||||
}
|
||||
}
|
||||
|
||||
bool batchSetups(pair<string, string >tracePair, vector<DramSetup> setups)
|
||||
{
|
||||
int id =0;
|
||||
for(auto& setup : setups)
|
||||
{
|
||||
id++;
|
||||
string traceName = "batch0" + to_string(id) + ".tdb";
|
||||
if(runSimulation(resources, traceName, setup, { Device(tracePair.first), Device(tracePair.second) }))
|
||||
return true;//kill child
|
||||
}
|
||||
}
|
||||
int sc_main(int argc, char **argv)
|
||||
{
|
||||
sc_set_time_resolution(1, SC_PS);
|
||||
|
||||
string resources = pathOfFile(argv[0]) + string("/../resources/");
|
||||
resources = pathOfFile(argv[0]) + string("/../resources/");
|
||||
|
||||
DramSetup setup;
|
||||
setup.memconfig = "memconfig.xml";
|
||||
setup.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
setup.memspec = "MatzesWideIO.xml";
|
||||
|
||||
Device device1;
|
||||
device1.trace = "empty.stl";
|
||||
DramSetup setup;
|
||||
setup.memconfig = "memconfig.xml";
|
||||
//setup.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
setup.memspec = "MatzesWideIO.xml";
|
||||
|
||||
Device device2;
|
||||
device2.trace = "trace.stl";
|
||||
//device2.trace = "mediabench-h263decode_32.stl";
|
||||
DramSetup setup2;
|
||||
setup2.memconfig = "memconfig.xml";
|
||||
setup2.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
|
||||
|
||||
string traceName = "tpr.tdb";
|
||||
|
||||
SimulationManager simulationManager("sim", resources, traceName, setup, { device1, device2 });
|
||||
simulationManager.startSimulation();
|
||||
startTraceAnalyzer(traceName);
|
||||
vector<pair<string, string>> tracePairs;
|
||||
tracePairs.push_back(pair<string, string>("trace.stl", "empty.stl"));
|
||||
tracePairs.push_back(pair<string, string>("trace2.stl", "empty.stl"));
|
||||
//batchTraces(setup, tracePairs);
|
||||
batchSetups(tracePairs[0], {setup, setup2});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user