OpenASIP  2.0
Public Member Functions | List of all members
InfoStatsCommand Class Reference
Inheritance diagram for InfoStatsCommand:
Inheritance graph
Collaboration diagram for InfoStatsCommand:
Collaboration graph

Public Member Functions

 InfoStatsCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~InfoStatsCommand ()
 
virtual bool execute (const std::vector< DataObject > &arguments)
 
- Public Member Functions inherited from SimControlLanguageSubCommand
 SimControlLanguageSubCommand (SimControlLanguageCommand &parentCommand)
 
virtual ~SimControlLanguageSubCommand ()
 
virtual SimControlLanguageCommandparent ()
 

Detailed Description

Implementation of "info stats". The following sub-commands are supported: "executed_operations", "register_reads" and "register_writes"

Definition at line 1120 of file InfoCommand.cc.

Constructor & Destructor Documentation

◆ InfoStatsCommand()

InfoStatsCommand::InfoStatsCommand ( SimControlLanguageCommand parentCommand)
inline

Constructor.

Definition at line 1125 of file InfoCommand.cc.

1125  :
1126  SimControlLanguageSubCommand(parentCommand) {
1127  }

◆ ~InfoStatsCommand()

virtual InfoStatsCommand::~InfoStatsCommand ( )
inlinevirtual

Destructor.

Definition at line 1132 of file InfoCommand.cc.

1132  {
1133  }

Member Function Documentation

◆ execute()

virtual bool InfoStatsCommand::execute ( const std::vector< DataObject > &  arguments)
inlinevirtual

Executes the "info stats" command.

Parameters
argumentsArguments to the command, including the command.
Returns
true in case execution was successful.

Implements SimControlLanguageSubCommand.

Definition at line 1141 of file InfoCommand.cc.

1141  {
1142  if (!parent().checkSimulationEnded() &&
1143  !parent().checkSimulationInitialized() &&
1144  !parent().checkSimulationStopped() &&
1145  !parent().simulatorFrontend().isSimulationRunning()) {
1146  return false;
1147  }
1148 
1149  const int argumentCount = arguments.size() - 2;
1150 
1151  if (!parent().checkArgumentCount(argumentCount, 1, 1)) {
1152  return false;
1153  }
1154 
1155  const std::string command =
1156  StringTools::stringToLower(arguments[2].stringValue());
1157 
1158  const UtilizationStats& stats =
1160 
1161  const TTAMachine::Machine& mach =
1163 
1164  ClockCycleCount totalOperationExecutions = 0;
1165  ClockCycleCount totalRegisterReads = 0;
1166  ClockCycleCount totalRegisterWrites = 0;
1167 
1169  mach.functionUnitNavigator();
1170 
1172  mach.registerFileNavigator();
1173 
1174  if (command == "executed_operations") {
1175  for (int i = 0; i <= fuNav.count(); ++i) {
1176  TTAMachine::FunctionUnit* fu = NULL;
1177  if (i < fuNav.count())
1178  fu = fuNav.item(i);
1179  else
1180  fu = mach.controlUnit();
1181  assert(fu != NULL);
1182 
1183  for (int j = 0; j < fu->operationCount(); ++j) {
1184  const TTAMachine::HWOperation* op = fu->operation(j);
1185  assert (op != NULL);
1186  totalOperationExecutions += stats.operationExecutions(
1187  fu->name(), StringTools::stringToUpper(op->name()));
1188  }
1189  }
1191  static_cast<double>(totalOperationExecutions));
1192  return true;
1193  } else if (command == "register_reads") {
1194  for (int i = 0; i < rfNav.count(); ++i) {
1195  TTAMachine::RegisterFile* rf = rfNav.item(i);
1196  assert(rf != NULL);
1197 
1198  int lastReg = 0;
1199  lastReg = rf->numberOfRegisters() - 1;
1200  for (int reg = 0; reg <= lastReg; ++reg) {
1201  totalRegisterReads += stats.registerReads(rf->name(), reg);
1202  }
1203  }
1205  static_cast<double>(totalRegisterReads));
1206  return true;
1207 
1208  } else if (command == "register_writes") {
1209  for (int i = 0; i < rfNav.count(); ++i) {
1210  TTAMachine::RegisterFile* rf = rfNav.item(i);
1211  assert(rf != NULL);
1212 
1213  int lastReg = 0;
1214  lastReg = rf->numberOfRegisters() - 1;
1215  for (int reg = 0; reg <= lastReg; ++reg) {
1216  totalRegisterWrites += stats.registerWrites(rf->name(), reg);
1217  }
1218  }
1220  static_cast<double>(totalRegisterWrites));
1221  return true;
1222 
1223  } else {
1227  return false;
1228  }
1229  }

References assert, TTAMachine::Machine::controlUnit(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), CustomCommand::interpreter(), TTAMachine::Machine::Navigator< ComponentType >::item(), SimulatorFrontend::machine(), TTAMachine::HWOperation::name(), TTAMachine::Component::name(), TTAMachine::BaseRegisterFile::numberOfRegisters(), TTAMachine::FunctionUnit::operation(), TTAMachine::FunctionUnit::operationCount(), UtilizationStats::operationExecutions(), SimControlLanguageSubCommand::parent(), TTAMachine::Machine::registerFileNavigator(), UtilizationStats::registerReads(), UtilizationStats::registerWrites(), ScriptInterpreter::setError(), ScriptInterpreter::setResult(), SimControlLanguageCommand::simulatorFrontend(), StringTools::stringToLower(), StringTools::stringToUpper(), SimulatorToolbox::textGenerator(), Texts::TXT_UNKNOWN_SUBCOMMAND, and SimulatorFrontend::utilizationStatistics().

Here is the call graph for this function:

The documentation for this class was generated from the following file:
SimControlLanguageSubCommand::parent
virtual SimControlLanguageCommand & parent()
Definition: SimControlLanguageCommand.cc:842
SimControlLanguageSubCommand::SimControlLanguageSubCommand
SimControlLanguageSubCommand(SimControlLanguageCommand &parentCommand)
Definition: SimControlLanguageCommand.cc:824
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TTAMachine::HWOperation
Definition: HWOperation.hh:52
SimulatorFrontend::machine
const TTAMachine::Machine & machine() const
Definition: SimulatorFrontend.cc:263
TTAMachine::Machine::Navigator::count
int count() const
TTAMachine::BaseRegisterFile::numberOfRegisters
virtual int numberOfRegisters() const
StringTools::stringToUpper
static std::string stringToUpper(const std::string &source)
Definition: StringTools.cc:143
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::Machine::controlUnit
virtual ControlUnit * controlUnit() const
Definition: Machine.cc:345
TTAMachine::HWOperation::name
const std::string & name() const
Definition: HWOperation.cc:141
SimulatorFrontend::utilizationStatistics
const UtilizationStats & utilizationStatistics(int core=-1)
Definition: SimulatorFrontend.cc:2155
Texts::TXT_UNKNOWN_SUBCOMMAND
@ TXT_UNKNOWN_SUBCOMMAND
Definition: TextGenerator.hh:65
SimulatorToolbox::textGenerator
static SimulatorTextGenerator & textGenerator()
Definition: SimulatorToolbox.cc:75
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
UtilizationStats::operationExecutions
ClockCycleCount operationExecutions(const std::string &operationName) const
Definition: UtilizationStats.cc:234
TTAMachine::FunctionUnit::operationCount
virtual int operationCount() const
Definition: FunctionUnit.cc:419
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
ScriptInterpreter::setResult
virtual void setResult(DataObject *result)
Definition: ScriptInterpreter.cc:128
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
UtilizationStats::registerWrites
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:314
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
ScriptInterpreter::setError
virtual void setError(bool state)
Definition: ScriptInterpreter.cc:205
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
UtilizationStats::registerReads
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
Definition: UtilizationStats.cc:270
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
SimControlLanguageCommand::simulatorFrontend
SimulatorFrontend & simulatorFrontend()
Definition: SimControlLanguageCommand.cc:214
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
StringTools::stringToLower
static std::string stringToLower(const std::string &source)
Definition: StringTools.cc:160
UtilizationStats
Definition: UtilizationStats.hh:50
TTAMachine::Machine
Definition: Machine.hh:73