tlm protocol, record in interface methods
This commit is contained in:
@@ -15,7 +15,7 @@ using namespace simulation;
|
||||
namespace simulation {
|
||||
|
||||
SimulationManager::SimulationManager(string resources) :
|
||||
resources(resources)
|
||||
resources(resources), silent(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -23,56 +23,79 @@ SimulationManager::~SimulationManager()
|
||||
{
|
||||
}
|
||||
|
||||
void SimulationManager::loadSimulationFromXML(string uri)
|
||||
void SimulationManager::loadSimulationsFromXML(string uri)
|
||||
{
|
||||
cout << "\n\nLoad Simulation-Batch:"<<endl;
|
||||
cout << headline<< endl;
|
||||
cout << "\t-> load simulation from .."<<endl;
|
||||
cout << "\n\nLoad Simulation-Batchs:" << endl;
|
||||
cout << headline << endl;
|
||||
cout << "\t-> load simulations .." << endl;
|
||||
|
||||
exportPath = getFileName(uri);
|
||||
XMLDocument doc;
|
||||
loadXML(uri, doc);
|
||||
|
||||
cout << "\t-> parsing simulation object .."<<endl;
|
||||
simulationName = getFileName(uri);
|
||||
parseXML(doc);
|
||||
cout << "\t-> parsing simulation objects .." << endl;
|
||||
|
||||
cout << "\t-> checking paths .."<<endl;
|
||||
|
||||
for (XMLElement* element = doc.FirstChildElement("simulation"); element != NULL;
|
||||
element = element->NextSiblingElement("simulation"))
|
||||
{
|
||||
parseSimulationBatch(element);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
cout << "\t-> checking paths .." << endl;
|
||||
checkPaths();
|
||||
|
||||
cout << "\t-> simulation loaded successfully!\n"<<endl;
|
||||
printSimulationBatch();
|
||||
cout << "\t-> simulation batches loaded successfully!\n" << endl;
|
||||
|
||||
for (auto batch : simulationsBatches)
|
||||
{
|
||||
batch.print();
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationManager::runSimulations()
|
||||
{
|
||||
system(string("mkdir -p " + simulationName).c_str());
|
||||
|
||||
for (auto& dramSetup : dramSetups)
|
||||
system(string("rm -rf " + exportPath).c_str());
|
||||
for (auto& batch : simulationsBatches)
|
||||
{
|
||||
string memconfig = getFileName(dramSetup.memconfig);
|
||||
for (auto& traceSetup : traceSetups)
|
||||
system(string("mkdir -p " + exportPath + "/"+batch.simulationName).c_str());
|
||||
|
||||
for (auto& dramSetup : batch.dramSetups)
|
||||
{
|
||||
runSimulation(simulationName + "/" + memconfig + "-" + traceSetup.first + ".tdb", dramSetup, traceSetup.second);
|
||||
string memconfig = getFileName(dramSetup.memconfig);
|
||||
for (auto& traceSetup : batch.traceSetups)
|
||||
{
|
||||
runSimulation(exportPath + "/" + batch.simulationName + "/" + memconfig + "-" + traceSetup.first + ".tdb",
|
||||
dramSetup, traceSetup.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SimulationManager::parseXML(XMLDocument& doc)
|
||||
void SimulationManager::parseSimulationBatch(XMLElement* simulation)
|
||||
{
|
||||
XMLElement* simulation = doc.FirstChildElement("simulation");
|
||||
SimulationBatch batch;
|
||||
|
||||
batch.simulationName = simulation->Attribute("id");
|
||||
string memspecUri = simulation->FirstChildElement("memspec")->GetText();
|
||||
string addressmappingUri = simulation->FirstChildElement("addressmapping")->GetText();
|
||||
|
||||
for (XMLElement* element = simulation->FirstChildElement("memconfigs")->FirstChildElement("memconfig"); element != NULL;
|
||||
element = element->NextSiblingElement("memconfig"))
|
||||
{
|
||||
dramSetups.push_back(DramSetup(element->GetText(), memspecUri, addressmappingUri));
|
||||
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(element);
|
||||
addTraceSetup(batch, element);
|
||||
}
|
||||
|
||||
simulationsBatches.push_back(batch);
|
||||
}
|
||||
|
||||
void SimulationManager::checkPaths()
|
||||
@@ -98,32 +121,39 @@ void SimulationManager::runSimulation(string traceName, DramSetup dramSetup, vec
|
||||
void SimulationManager::startTraceAnalyzer()
|
||||
{
|
||||
string p = getenv("trace");
|
||||
string run_tpr = p + " -f " + simulationName + "&";
|
||||
string run_tpr = p + " -f ";
|
||||
for(auto batch : simulationsBatches)
|
||||
{
|
||||
run_tpr += exportPath + "/" + batch.simulationName + " ";
|
||||
|
||||
}
|
||||
run_tpr += "&";
|
||||
system(run_tpr.c_str());
|
||||
}
|
||||
|
||||
void SimulationManager::addTraceSetup(tinyxml2::XMLElement* element)
|
||||
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)
|
||||
while (devices.size() < Simulation::NumberOfTracePlayers)
|
||||
{
|
||||
devices.push_back(Device());
|
||||
}
|
||||
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;
|
||||
cout << message << endl;
|
||||
}
|
||||
|
||||
void SimulationManager::printSimulationBatch()
|
||||
void SimulationBatch::print()
|
||||
{
|
||||
for (DramSetup& s : dramSetups)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user