The Statistic Capability allow to generate various statistics tied to the simulation such as the cache miss rate, number of instruction executed and so on.
The Statistic File Capability allows to save some of the statistics computed during the simulation to an output file, and to reload those statistics for future simulations.
Such a capability enable different uses:
The Statistic File Interface is very simple, just providing a method to either create a new statistic file or reload an existing one, then some methods to add new statistics and to save the statistic repository to a file.
The interface for the Statistic File Capability is defined by the StatisticFile class presented below:
class StatisticFile {public: StatisticFile () // Creates a new empty Statistic File StatisticFile (const string &name) // Creates a Statistic File by reading an input file void add (const string &name, T value) // Add a new statistic of type T to the repository const T operator[ ] (const string&) // Access a statistic from the repository void save (const string &name) // Save the statistic repository to an output file. }
The next section describes how to use the statistic file capability within your own simulators.
To illustrate the use of the Statistic File Capability we’ll add:
Adding the following code at the end of your ISS will allow it to dump statistics:
StatisticFile f; double speed = cpu->GetInstructionCounter() / spent_time; f.add("instruction_count",cpu->GetInstructionCounter()); f.add("emulation_time",spent_time); f.add("speed",speed); f.save("dump-statistics");
The statistics consisting of:
The first one will allow us to compute the estimated ETA in the cycle-level simulator, the last two ones could be used to compute the cycle-level over ISS slowdown.
Then the cycle level simulator needs to be modified to reload the ISS statistic before the main simulation loop, adding the following source code:
StatisticFile statfile("dump-statistics"); predicted_total_instructions = statfile["instruction_count"];
Last, we can add our “progress indicator” to the main simulation loop, even if it is not the most efficent way to do so, as it will slow the simulator a lot:
cerr << commited_instructions << "/" << predicted_total_instructions << endl;
A more efficient way would be to do this in a separated thread refreshing the indicator every few seconds or so.