changed project structure to qtcreator, added timed out powerdown
This commit is contained in:
@@ -15,7 +15,7 @@ using namespace simulation;
|
||||
namespace simulation {
|
||||
|
||||
SimulationManager::SimulationManager(string resources) :
|
||||
resources(resources), silent(false)
|
||||
resources(resources), silent(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -25,160 +25,160 @@ SimulationManager::~SimulationManager()
|
||||
|
||||
void SimulationManager::loadSimulationsFromXML(string uri)
|
||||
{
|
||||
cout << "\n\nLoad Simulation-Batchs:" << endl;
|
||||
cout << headline << endl;
|
||||
cout << "\t-> load simulations .." << endl;
|
||||
cout << "\n\nLoad Simulation-Batchs:" << endl;
|
||||
cout << headline << endl;
|
||||
cout << "\t-> load simulations .." << endl;
|
||||
|
||||
exportPath = getFileName(uri);
|
||||
XMLDocument doc;
|
||||
loadXML(uri, doc);
|
||||
exportPath = getFileName(uri);
|
||||
XMLDocument doc;
|
||||
loadXML(uri, doc);
|
||||
|
||||
cout << "\t-> parsing simulation objects .." << endl;
|
||||
cout << "\t-> parsing simulation objects .." << endl;
|
||||
|
||||
for (XMLElement* element = doc.FirstChildElement("simulation"); element != NULL;
|
||||
element = element->NextSiblingElement("simulation"))
|
||||
{
|
||||
parseSimulationBatch(element);
|
||||
}
|
||||
for (XMLElement* element = doc.FirstChildElement("simulation"); element != NULL;
|
||||
element = element->NextSiblingElement("simulation"))
|
||||
{
|
||||
parseSimulationBatch(element);
|
||||
}
|
||||
|
||||
cout << "\t-> checking paths .." << endl;
|
||||
checkPaths();
|
||||
cout << "\t-> checking paths .." << endl;
|
||||
checkPaths();
|
||||
|
||||
cout << "\t-> simulation batches loaded successfully!\n" << endl;
|
||||
cout << "\t-> simulation batches loaded successfully!\n" << endl;
|
||||
|
||||
for (auto batch : simulationsBatches)
|
||||
{
|
||||
batch.print();
|
||||
}
|
||||
for (auto batch : simulationsBatches)
|
||||
{
|
||||
batch.print();
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationManager::runSimulations()
|
||||
{
|
||||
system(string("rm -rf " + exportPath).c_str());
|
||||
for (auto& batch : simulationsBatches)
|
||||
{
|
||||
system(string("mkdir -p " + exportPath + "/" + batch.simulationName).c_str());
|
||||
// system(string("rm -rf " + exportPath).c_str());
|
||||
for (auto& batch : simulationsBatches)
|
||||
{
|
||||
//system(string("mkdir -p " + exportPath + "/" + batch.simulationName).c_str());
|
||||
|
||||
for (auto& dramSetup : batch.dramSetups)
|
||||
{
|
||||
string memconfig = getFileName(dramSetup.memconfig);
|
||||
string memspec = getFileName(dramSetup.memspec);
|
||||
string addressmappig = getFileName(dramSetup.addressmapping);
|
||||
for (auto& dramSetup : batch.dramSetups)
|
||||
{
|
||||
string memconfig = getFileName(dramSetup.memconfig);
|
||||
string memspec = getFileName(dramSetup.memspec);
|
||||
string addressmappig = getFileName(dramSetup.addressmapping);
|
||||
|
||||
for (auto& traceSetup : batch.traceSetups)
|
||||
{
|
||||
runSimulation(
|
||||
exportPath + "/" + batch.simulationName + "/" + traceSetup.first + "-" + memspec + "-" +
|
||||
memconfig + ".tdb", dramSetup, traceSetup.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (auto& traceSetup : batch.traceSetups)
|
||||
{
|
||||
runSimulation(
|
||||
exportPath + "/" + batch.simulationName + "/" + traceSetup.first + "-" + memspec + "-" +
|
||||
memconfig + ".tdb", dramSetup, traceSetup.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationManager::parseSimulationBatch(XMLElement* simulation)
|
||||
{
|
||||
SimulationBatch batch;
|
||||
SimulationBatch batch;
|
||||
|
||||
batch.simulationName = simulation->Attribute("id");
|
||||
batch.simulationName = simulation->Attribute("id");
|
||||
|
||||
string memspecUri;
|
||||
string addressmappingUri;
|
||||
string memspecUri;
|
||||
string addressmappingUri;
|
||||
|
||||
for (XMLElement* element = simulation->FirstChildElement("memspec"); element != NULL;
|
||||
element = element->NextSiblingElement("memspec"))
|
||||
{
|
||||
memspecUri = element->GetText();
|
||||
for (XMLElement* element = simulation->FirstChildElement("addressmapping"); element != NULL;
|
||||
element = element->NextSiblingElement("addressmapping"))
|
||||
{
|
||||
addressmappingUri = element->GetText();
|
||||
for (XMLElement* element = simulation->FirstChildElement("memconfigs")->FirstChildElement("memconfig");
|
||||
element != NULL; element = element->NextSiblingElement("memconfig"))
|
||||
{
|
||||
batch.dramSetups.push_back(DramSetup(element->GetText(), memspecUri, addressmappingUri));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (XMLElement* element = simulation->FirstChildElement("memspec"); element != NULL;
|
||||
element = element->NextSiblingElement("memspec"))
|
||||
{
|
||||
memspecUri = element->GetText();
|
||||
for (XMLElement* element = simulation->FirstChildElement("addressmapping"); element != NULL;
|
||||
element = element->NextSiblingElement("addressmapping"))
|
||||
{
|
||||
addressmappingUri = element->GetText();
|
||||
for (XMLElement* element = simulation->FirstChildElement("memconfigs")->FirstChildElement("memconfig");
|
||||
element != NULL; element = element->NextSiblingElement("memconfig"))
|
||||
{
|
||||
batch.dramSetups.push_back(DramSetup(element->GetText(), memspecUri, addressmappingUri));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (XMLElement* element = simulation->FirstChildElement("trace-setups")->FirstChildElement("trace-setup"); element != NULL;
|
||||
element = element->NextSiblingElement("trace-setup"))
|
||||
{
|
||||
addTraceSetup(batch, element);
|
||||
}
|
||||
for (XMLElement* element = simulation->FirstChildElement("trace-setups")->FirstChildElement("trace-setup"); element != NULL;
|
||||
element = element->NextSiblingElement("trace-setup"))
|
||||
{
|
||||
addTraceSetup(batch, element);
|
||||
}
|
||||
|
||||
simulationsBatches.push_back(batch);
|
||||
simulationsBatches.push_back(batch);
|
||||
|
||||
}
|
||||
|
||||
void SimulationManager::checkPaths()
|
||||
{
|
||||
//reportFatal("Simulation Manager", "Not all paths in xml are valid");
|
||||
//reportFatal("Simulation Manager", "Not all paths in xml are valid");
|
||||
}
|
||||
|
||||
void SimulationManager::runSimulation(string traceName, DramSetup dramSetup, vector<Device> traceSetup)
|
||||
{
|
||||
int pid = fork();
|
||||
int status = 0;
|
||||
if (pid == 0)
|
||||
{
|
||||
Simulation* simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup, silent);
|
||||
simulation->start();
|
||||
delete simulation;
|
||||
_Exit(0);
|
||||
}
|
||||
int pid = fork();
|
||||
int status = 0;
|
||||
if (pid == 0)
|
||||
{
|
||||
Simulation* simulation = new Simulation("sim", resources, traceName, dramSetup, traceSetup, silent);
|
||||
simulation->start();
|
||||
delete simulation;
|
||||
_Exit(0);
|
||||
}
|
||||
|
||||
waitpid(pid, &status, 0);
|
||||
waitpid(pid, &status, 0);
|
||||
}
|
||||
|
||||
void SimulationManager::startTraceAnalyzer()
|
||||
{
|
||||
string p = getenv("trace");
|
||||
string run_tpr = p + " -f ";
|
||||
for (auto batch : simulationsBatches)
|
||||
{
|
||||
run_tpr += exportPath + "/" + batch.simulationName + " ";
|
||||
string p = getenv("trace");
|
||||
string run_tpr = p + " -f ";
|
||||
for (auto batch : simulationsBatches)
|
||||
{
|
||||
run_tpr += exportPath + "/" + batch.simulationName + " ";
|
||||
|
||||
}
|
||||
run_tpr += "&";
|
||||
system(run_tpr.c_str());
|
||||
}
|
||||
run_tpr += "&";
|
||||
system(run_tpr.c_str());
|
||||
}
|
||||
|
||||
void SimulationManager::addTraceSetup(SimulationBatch& batch, tinyxml2::XMLElement* element)
|
||||
{
|
||||
vector<Device> devices;
|
||||
for (XMLElement* device = element->FirstChildElement("device"); device != NULL; device = device->NextSiblingElement("device"))
|
||||
{
|
||||
devices.push_back(Device(device->GetText(), device->IntAttribute("bl")));
|
||||
}
|
||||
while (devices.size() < Simulation::NumberOfTracePlayers)
|
||||
{
|
||||
devices.push_back(Device());
|
||||
}
|
||||
vector<Device> devices;
|
||||
for (XMLElement* device = element->FirstChildElement("device"); device != NULL; device = device->NextSiblingElement("device"))
|
||||
{
|
||||
devices.push_back(Device(device->GetText(), device->IntAttribute("bl")));
|
||||
}
|
||||
while (devices.size() < Simulation::NumberOfTracePlayers)
|
||||
{
|
||||
devices.push_back(Device());
|
||||
}
|
||||
|
||||
batch.traceSetups.emplace(element->Attribute("id"), devices);
|
||||
batch.traceSetups.emplace(element->Attribute("id"), devices);
|
||||
}
|
||||
|
||||
void SimulationManager::report(string message)
|
||||
{
|
||||
//DebugManager::getInstance().printDebugMessage("Simulation Manager", message);
|
||||
//if (DebugManager::getInstance().writeToConsole == false)
|
||||
cout << message << endl;
|
||||
//DebugManager::getInstance().printDebugMessage("Simulation Manager", message);
|
||||
//if (DebugManager::getInstance().writeToConsole == false)
|
||||
cout << message << endl;
|
||||
}
|
||||
|
||||
void SimulationBatch::print()
|
||||
{
|
||||
for (DramSetup& s : dramSetups)
|
||||
{
|
||||
cout << s.memspec << " - " << s.memconfig << endl;
|
||||
}
|
||||
cout << endl;
|
||||
for (auto& s : traceSetups)
|
||||
{
|
||||
cout << "trace-setup " + s.first + ":\n";
|
||||
for (Device d : s.second)
|
||||
cout << "\t(" << d.burstLength << ") " << d.trace << ";" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
for (DramSetup& s : dramSetups)
|
||||
{
|
||||
cout << s.memspec << " - " << s.memconfig << endl;
|
||||
}
|
||||
cout << endl;
|
||||
for (auto& s : traceSetups)
|
||||
{
|
||||
cout << "trace-setup " + s.first + ":\n";
|
||||
for (Device d : s.second)
|
||||
cout << "\t(" << d.burstLength << ") " << d.trace << ";" << endl;
|
||||
cout << endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user