cool simulation manager

This commit is contained in:
Janik Schlemminger
2014-04-12 20:43:10 +02:00
parent a1444a4d7b
commit e9633c1b30
18 changed files with 413 additions and 244 deletions

View File

@@ -11,10 +11,11 @@
#include "../core/configuration/Configuration.h"
#include <systemc.h>
#include <sys/wait.h>
#include <utility>
#include <vector>
using namespace std;
using namespace simulation;
@@ -25,88 +26,22 @@ string pathOfFile(string file)
return file.substr(0, file.find_last_of('/'));
}
void startTraceAnalyzer(string traceName)
int main(int argc, char **argv)
{
string p = getenv("trace");
string run_tpr = p + " " + traceName;
system(run_tpr.c_str());
return sc_main(argc, argv);
}
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, false);
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
}
return false;
}
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
}
return false;
}
int sc_main(int argc, char **argv)
{
sc_set_time_resolution(1, SC_PS);
resources = pathOfFile(argv[0]) + string("/../resources/");
DramSetup setup;
setup.memconfig = "memconfig.xml";
setup.memspec = "MatzesWideIO.xml";
setup.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
SimulationManager manager(resources);
manager.loadSimulationFromXML("/home/jonny/git/dram.vp.system/dram/resources/simulations/first.xml");
manager.runSimulations();
DramSetup setup2;
setup2.memconfig = "memconfig.xml";
setup2.memspec = "MICRON_4Gb_DDR4-1866_8bit_A.xml";
manager.startTraceAnalyzer();
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});
string traceName("tpr5.tdb");
string trace2 = "empty.stl";
string trace1 = "chstone-jpeg_32.stl";
trace1 = "mediabench-adpcmencode_32.stl";
//trace1 = "mediabench-h263encode_32.stl";
//trace1 = "trace.stl";
if (runSimulation(resources, traceName, setup, { Device(trace1), Device(trace2) }))
startTraceAnalyzer(traceName);
return 0;
}