simulation manager extended to 4 player, refactoring, porno progress bar

This commit is contained in:
Janik Schlemminger
2014-04-13 01:30:38 +02:00
parent 40d6a0e6f0
commit 8d07af4431
14 changed files with 190 additions and 98 deletions

View File

@@ -20,31 +20,8 @@ using namespace std;
namespace simulation {
Simulation::Simulation(string name, string pathToResources, string traceName, DramSetup setup,
std::vector<Device> devices, bool silent) :
traceName(traceName), senderName(name)
void Simulation::setupDebugManager(bool silent, const string& traceName)
{
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/addressConfig.xml");
TlmRecorder::dbName = traceName;
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
//setup dram
dram = new Dram<>("dram");
arbiter = new Arbiter<numberOfTracePlayers, 128>("arbiter");
controller = new Controller<>("controller");
player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, this);
player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, this);
player1->iSocket.bind(arbiter->tSockets[0]);
player2->iSocket.bind(arbiter->tSockets[1]);
arbiter->iSocket.bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
vector<string> whiteList;
if (!silent)
{
@@ -56,7 +33,6 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr
whiteList.push_back(ControllerCore::senderName);
whiteList.push_back(PowerDownManagerBankwise::senderName);
}
auto& dbg = DebugManager::getInstance();
dbg.addToWhiteList(whiteList);
dbg.setDebugFile(traceName + ".txt");
@@ -65,12 +41,44 @@ Simulation::Simulation(string name, string pathToResources, string traceName, Dr
dbg.writeToConsole = false;
dbg.writeToFile = false;
}
}
Simulation::Simulation(string name, string pathToResources, string traceName, DramSetup setup, std::vector<Device> devices,
bool silent) :
traceName(traceName), senderName(name), dramSetup(setup)
{
xmlAddressDecoder::addressConfigURI = pathToResources + string("configs/amconfigs/") + setup.addressmapping;
TlmRecorder::dbName = traceName;
TlmRecorder::sqlScriptURI = pathToResources + string("scripts/createTraceDB.sql");
Configuration::memconfigUri = pathToResources + string("configs/memconfigs/") + setup.memconfig;
Configuration::memspecUri = pathToResources + string("configs/memspecs/") + setup.memspec;
dram = new Dram<>("dram");
arbiter = new Arbiter<NumberOfTracePlayers, 128>("arbiter");
controller = new Controller<>("controller");
player1 = new TracePlayer<>("player1", pathToResources + string("traces/") + devices[0].trace, devices[0].burstLength, this);
player2 = new TracePlayer<>("player2", pathToResources + string("traces/") + devices[1].trace, devices[1].burstLength, this);
player3 = new TracePlayer<>("player3", pathToResources + string("traces/") + devices[2].trace, devices[2].burstLength, this);
player4 = new TracePlayer<>("player4", pathToResources + string("traces/") + devices[3].trace, devices[3].burstLength, this);
player1->iSocket.bind(arbiter->tSockets[0]);
player2->iSocket.bind(arbiter->tSockets[1]);
player3->iSocket.bind(arbiter->tSockets[2]);
player4->iSocket.bind(arbiter->tSockets[3]);
arbiter->iSocket.bind(controller->tSocket);
controller->iSocket.bind(dram->tSocket);
setupDebugManager(silent, traceName);
totalTransactions = getNumberOfLines(pathToResources + string("traces/") + devices[0].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[1].trace);
cout << "Total transactions: " << totalTransactions << endl;
remainingTransactions = totalTransactions;
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[2].trace);
totalTransactions += getNumberOfLines(pathToResources + string("traces/") + devices[3].trace);
remainingTransactions = totalTransactions;
}
Simulation::~Simulation()
@@ -80,16 +88,23 @@ Simulation::~Simulation()
delete controller;
delete player1;
delete player2;
delete player3;
delete player4;
}
void Simulation::start()
{
cout << "Starting simulation:" << endl;
report("\n\nStarting simulation:");
report(headline);
report(" -> setup: \t\t" + getFileName(traceName));
report(" -> memspec: \t\t" + Configuration::getInstance().MemoryId);
report(" -> transactions: \t" + to_string(totalTransactions));
cout<<endl;
simulationStartTime = clock();
DebugManager::getInstance().printDebugMessage(senderName, "Starting simulation");
player1->start();
player2->start();
sc_set_stop_mode(SC_STOP_FINISH_DELTA);
player3->start();
player4->start();
sc_start();
}
@@ -97,22 +112,27 @@ void inline Simulation::transactionFinished()
{
remainingTransactions--;
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if(remainingTransactions == 0)
if (remainingTransactions == 0)
{
cout<<endl;
stop();
}
}
void Simulation::stop()
{
report("\nTerminating simulation");
controller->terminateSimulation();
DebugManager::getInstance().printDebugMessage(senderName, "Terminating simulation");
TlmRecorder::getInstance().closeConnection();
sc_stop();
double elapsed_secs = double(clock() - simulationStartTime) / CLOCKS_PER_SEC;
DebugManager::getInstance().printDebugMessage(senderName, "Simulation took " + to_string(elapsed_secs) + " seconds");
cout << "\nSimulation took: " << (elapsed_secs) << endl;
report("Simulation took " + to_string(elapsed_secs) + " seconds");
}
void Simulation::report(string message)
{
DebugManager::getInstance().printDebugMessage(senderName, message);
cout << message << endl;
}
unsigned int Simulation::getNumberOfLines(string uri)