OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
SimulationStatistics Class Reference

#include <SimulationStatistics.hh>

Collaboration diagram for SimulationStatistics:
Collaboration graph

Public Member Functions

 SimulationStatistics (const TTAProgram::Program &programData, const InstructionMemory &executionCounts)
 
virtual ~SimulationStatistics ()
 
void addStatistics (SimulationStatisticsCalculator &statisticsType)
 
void calculate ()
 

Private Attributes

std::vector< SimulationStatisticsCalculator * > statisticsTypes_
 All registered statistics types are stored in this container. More...
 
const TTAProgram::Programprogram_
 The program used in calculating the statistics. More...
 
const InstructionMemoryexecutionCounts_
 The execution counts of instructions and moves in the program. More...
 

Detailed Description

Calculates simulation statistics using user-given calculation classes.

Definition at line 48 of file SimulationStatistics.hh.

Constructor & Destructor Documentation

◆ SimulationStatistics()

SimulationStatistics::SimulationStatistics ( const TTAProgram::Program programData,
const InstructionMemory executionCounts 
)

Constructs a new simulation statistics calculation loop.

Parameters
programDataThe program the statistics are calculated from.
executionCountsExecution counts of instructions and moves in the program.

Definition at line 48 of file SimulationStatistics.cc.

50  :
51  program_(programData), executionCounts_(executionCounts) {
52 }

◆ ~SimulationStatistics()

SimulationStatistics::~SimulationStatistics ( )
virtual

Destructor.

Definition at line 58 of file SimulationStatistics.cc.

58  {
59 }

Member Function Documentation

◆ addStatistics()

void SimulationStatistics::addStatistics ( SimulationStatisticsCalculator statisticsType)

Adds a new statistics type to be included in simulation statistics calculation.

Parameters
statisticsTypeNew statistics type.

Definition at line 68 of file SimulationStatistics.cc.

69  {
70  statisticsTypes_.push_back(&statisticsType);
71 }

References statisticsTypes_.

Referenced by SimulatorFrontend::utilizationStatistics().

◆ calculate()

void SimulationStatistics::calculate ( )

Calculates simulation statistics by going through the program and invoking calculate() for all statistics types.

Definition at line 78 of file SimulationStatistics.cc.

78  {
79 
80  if (statisticsTypes_.size() == 0)
81  return;
82 
83  const TTAProgram::Instruction* currentInstruction =
85  while (currentInstruction != &TTAProgram::NullInstruction::instance()) {
86 
87  // Skip implicit instructions they are processed already (see below).
88  if (currentInstruction->size() == 0) {
89  currentInstruction = &program_.nextInstruction(*currentInstruction);
90  continue;
91  }
92 
93  auto instrAddr = currentInstruction->address().location();
94  const ExecutableInstruction& execInstr =
96  if (execInstr.executionCount() == 0) {
97  currentInstruction =
98  &program_.nextInstruction(*currentInstruction);
99  continue;
100  }
101 
102  // First process explicit instruction ...
103  for (std::size_t i = 0; i < statisticsTypes_.size(); ++i) {
104  statisticsTypes_[i]->calculateForInstruction(
105  *currentInstruction, execInstr);
106  }
107 
108  // ... and then the following implicit instructions.
109  // FIXME: Potential breakage. Can not know if the executable instruction
110  // corresponds to the program instruction. It is now assumed the
111  // execution instructions are created and added to executionCounts_ in
112  // same order as program instructions currently being traversed.
114  *currentInstruction);
115  for (auto& implExecInstr : executionCounts_.implicitInstructionsAt(
116  instrAddr)) {
117  if (implInstr->size() != 0)
118  break;
119  for (std::size_t i = 0; i < statisticsTypes_.size(); ++i) {
120  statisticsTypes_[i]->calculateForInstruction(
121  *implInstr, *implExecInstr);
122  }
123  implInstr = &program_.nextInstruction(*implInstr);
124  }
125  currentInstruction = &program_.nextInstruction(*currentInstruction);
126  }
127 }

References TTAProgram::Instruction::address(), ExecutableInstruction::executionCount(), executionCounts_, InstructionMemory::implicitInstructionsAt(), TTAProgram::NullInstruction::instance(), TTAProgram::Program::instructionAt(), InstructionMemory::instructionAtConst(), TTAProgram::Address::location(), TTAProgram::Program::nextInstruction(), program_, TTAProgram::Instruction::size(), TTAProgram::Program::startAddress(), and statisticsTypes_.

Referenced by SimulatorFrontend::utilizationStatistics().

Here is the call graph for this function:

Member Data Documentation

◆ executionCounts_

const InstructionMemory& SimulationStatistics::executionCounts_
private

The execution counts of instructions and moves in the program.

Definition at line 64 of file SimulationStatistics.hh.

Referenced by calculate().

◆ program_

const TTAProgram::Program& SimulationStatistics::program_
private

The program used in calculating the statistics.

Definition at line 62 of file SimulationStatistics.hh.

Referenced by calculate().

◆ statisticsTypes_

std::vector<SimulationStatisticsCalculator*> SimulationStatistics::statisticsTypes_
private

All registered statistics types are stored in this container.

Definition at line 60 of file SimulationStatistics.hh.

Referenced by addStatistics(), and calculate().


The documentation for this class was generated from the following files:
InstructionMemory::instructionAtConst
const ExecutableInstruction & instructionAtConst(InstructionAddress address) const
ExecutableInstruction
Definition: ExecutableInstruction.hh:49
TTAProgram::Program::startAddress
Address startAddress() const
Definition: Program.cc:286
ExecutableInstruction::executionCount
ClockCycleCount executionCount() const
Definition: ExecutableInstruction.cc:85
TTAProgram::Program::nextInstruction
Instruction & nextInstruction(const Instruction &) const
Definition: Program.cc:403
InstructionMemory::implicitInstructionsAt
const InstructionContainer & implicitInstructionsAt(InstructionAddress addr) const
Definition: InstructionMemory.cc:128
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAProgram::Program::instructionAt
Instruction & instructionAt(InstructionAddress address) const
Definition: Program.cc:374
SimulationStatistics::executionCounts_
const InstructionMemory & executionCounts_
The execution counts of instructions and moves in the program.
Definition: SimulationStatistics.hh:64
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::Instruction::size
short size() const
Definition: Instruction.cc:365
SimulationStatistics::program_
const TTAProgram::Program & program_
The program used in calculating the statistics.
Definition: SimulationStatistics.hh:62
TTAProgram::Instruction::address
Address address() const
Definition: Instruction.cc:327
SimulationStatistics::statisticsTypes_
std::vector< SimulationStatisticsCalculator * > statisticsTypes_
All registered statistics types are stored in this container.
Definition: SimulationStatistics.hh:60