Simulation Progress Bar

This commit is contained in:
Felipe Salerno Prado
2016-05-11 14:04:29 +02:00
parent d359ed6ac3
commit 87e2fce2e7
11 changed files with 62 additions and 1 deletions

View File

@@ -9,6 +9,7 @@
<NumberOfMemChannels value="1"/>
<ControllerCoreDisableRefresh value="0"/>
<ThermalSimulation value="0"/>
<SimulationProgressBar value="1"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->

View File

@@ -9,6 +9,7 @@
<NumberOfMemChannels value="4"/>
<ControllerCoreDisableRefresh value="0"/>
<ThermalSimulation value="0"/>
<SimulationProgressBar value="1"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->

View File

@@ -163,6 +163,8 @@ void Configuration::setParameter(std::string name, std::string value)
ControllerCoreDisableRefresh = string2bool(value);
else if (name == "ThermalSimulation")
ThermalSimulation = string2bool(value);
else if(name == "SimulationProgressBar")
SimulationProgressBar = string2bool(value);
// Specification for ErrorChipSeed, ErrorCSVFile path and ErrorStoreMode
else if(name == "ErrorChipSeed")
ErrorChipSeed = string2int(value);

View File

@@ -82,6 +82,7 @@ struct Configuration
unsigned int NumberOfMemChannels = 1;
bool ControllerCoreDisableRefresh = false;
bool ThermalSimulation = false;
bool SimulationProgressBar;
//MemSpec(from DRAM-Power XML)
MemSpec memSpec;

View File

@@ -124,15 +124,20 @@ void Simulation::instantiateModules(const string &traceName, const string &pathT
StlPlayer<> *newPlayer = new StlPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
player = newPlayer;
newPlayer->getTraceLength(pathToResources + string("traces/") + devices[i].trace);
totalTransactions += newPlayer->getNumberOfLines(pathToResources + string("traces/") + devices[i].trace);
}
else
{
StlDataPlayer<> *newPlayer = new StlDataPlayer<>(playerStr.c_str(), pathToResources + string("traces/") + devices[i].trace, devices[i].clkMhz, this);
player = newPlayer;
newPlayer->getTraceLength(pathToResources + string("traces/") + devices[i].trace);
totalTransactions += newPlayer->getNumberOfLines(pathToResources + string("traces/") + devices[i].trace);
}
players.push_back(player);
}
remainingTransactions = totalTransactions;
//player->remainingTransactions = player->totalTransactions;
// Create and properly initialize TLM recorders. They need to be ready before creating some modules.
setupTlmRecorders(traceName, pathToResources, devices);
@@ -228,6 +233,17 @@ void Simulation::stop()
report("Simulation took " + to_string(elapsed_secs) + " seconds");
}
void inline Simulation::transactionFinished()
{
remainingTransactions--;
loadbar(totalTransactions - remainingTransactions, totalTransactions);
if (remainingTransactions == 0)
{
cout << endl;
}
}
void Simulation::report(string message)
{
DebugManager::getInstance().printDebugMessage(this->name(), message);

View File

@@ -86,6 +86,7 @@ public:
void stop();
virtual void tracePlayerTerminates() override;
virtual void transactionFinished() override;
private:
std::string traceName;
@@ -107,6 +108,9 @@ private:
// Transaction Recorders (one per channel). They generate the output databases.
std::vector<TlmRecorder*> tlmRecorders;
unsigned int totalTransactions = 0;
unsigned int remainingTransactions;
clock_t simulationStartTime;
void report(std::string message);
void setupTlmRecorders(const string &traceName, const string &pathToResources, const std::vector<Device> &devices);

View File

@@ -177,6 +177,19 @@ public:
}
unsigned int getNumberOfLines(string pathToTrace)
{
ifstream newFile;
newFile.open(pathToTrace);
newFile.unsetf(std::ios_base::skipws); // new lines will be skipped unless we stop it from happening:
// count the newlines with an algorithm specialized for counting:
unsigned int lineCount = std::count(std::istream_iterator<char>(newFile), std::istream_iterator<char>(), '\n');
newFile.close();
return lineCount;
}
private:
ifstream file;

View File

@@ -165,6 +165,18 @@ public:
}
unsigned int getNumberOfLines(string pathToTrace)
{
ifstream newFile;
newFile.open(pathToTrace);
newFile.unsetf(std::ios_base::skipws); // new lines will be skipped unless we stop it from happening:
// count the newlines with an algorithm specialized for counting:
unsigned int lineCount = std::count(std::istream_iterator<char>(newFile), std::istream_iterator<char>(), '\n');
newFile.close();
return lineCount;
}
private:
ifstream file;

View File

@@ -51,6 +51,7 @@
#include "../common/dramExtension.h"
#include "../controller/core/TimingCalculation.h"
#include "TracePlayerListener.h"
#include "Simulation.h"
using namespace std;
using namespace tlm;
@@ -96,7 +97,7 @@ gp *TracePlayer<BUSWIDTH>::allocatePayload()
template<unsigned int BUSWIDTH>
void TracePlayer<BUSWIDTH>::terminate()
{
cout << sc_time_stamp() << " " << this->name() << " terminated" << std::endl;
cout << sc_time_stamp() << " " << this->name() << " terminated " << std::endl;
listener->tracePlayerTerminates();
}
@@ -159,6 +160,9 @@ void TracePlayer<BUSWIDTH>::peqCallback(tlm_generic_payload &payload, const tlm_
sendToTarget(payload, END_RESP, SC_ZERO_TIME);
payload.release();
if(Configuration::getInstance().SimulationProgressBar)
listener->transactionFinished();
}
else if (phase == END_RESP)
{

View File

@@ -42,6 +42,7 @@ class TracePlayerListener
{
public:
virtual void tracePlayerTerminates() = 0;
virtual void transactionFinished() = 0;
};
#endif // TRACEPLAYERLISTENER_H

View File

@@ -324,6 +324,7 @@ The DRAMSys' main configuration file is presented below.
<NumberOfMemChannels value="4"/>
<ControllerCoreDisableRefresh value="0"/>
<ThermalSimulation value="1"/>
<SimulationProgressBar value="1"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->
@@ -423,6 +424,7 @@ The XML code below shows a typic configuration:
<NumberOfMemChannels value="1"/>
<ControllerCoreDisableRefresh value="0"/>
<ThermalSimulation value="0"/>
<SimulationProgressBar value="1"/>
</simconfig>
<!-- Temperature Simulator Configuration (used for all simulation setups) -->
@@ -542,6 +544,10 @@ Below are listed the configuration sections and configuration fields.
- *ThermalSimulation* (boolean)
- "1": enables thermal simulation
- "0": static temperature during simulation
- *SimulationProgressBar* (boolean)
- "1": enables the simulation progress bar
- "0": disables the simulation progress bar
- **Temperature Simulator Configuration**
- *TemperatureScale* (string)