OpenASIP 2.2
Loading...
Searching...
No Matches
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.

◆ ~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 }
#define assert(condition)
CycleCount ClockCycleCount
Alias for ClockCycleCount.
ScriptInterpreter * interpreter() const
virtual void setError(bool state)
virtual void setResult(DataObject *result)
virtual SimControlLanguageCommand & parent()
const TTAMachine::Machine & machine() const
const UtilizationStats & utilizationStatistics(int core=-1)
static SimulatorTextGenerator & textGenerator()
static std::string stringToUpper(const std::string &source)
static std::string stringToLower(const std::string &source)
virtual int numberOfRegisters() const
virtual TCEString name() const
virtual HWOperation * operation(const std::string &name) const
virtual int operationCount() const
const std::string & name() const
ComponentType * item(int index) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
virtual ControlUnit * controlUnit() const
Definition Machine.cc:345
ClockCycleCount operationExecutions(const std::string &operationName) const
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
@ TXT_UNKNOWN_SUBCOMMAND

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: