OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
UtilizationStats Class Reference

#include <UtilizationStats.hh>

Inheritance diagram for UtilizationStats:
Inheritance graph
Collaboration diagram for UtilizationStats:
Collaboration graph

Public Types

typedef std::map< std::string, ClockCycleCountComponentUtilizationIndex
 Index for connecting component names to utilization counts.
 
typedef std::map< int, std::pair< ClockCycleCount, ClockCycleCount > > RegisterUtilizationIndex
 Index for connecting register indices to utilization counts. The first number in the pair is the count of reads, and the second is the count of writes.
 
typedef std::map< std::string, ComponentUtilizationIndexFUOperationUtilizationIndex
 Index for connecting function unit and operations implemented in them to utilization counts.
 
typedef std::map< std::string, RegisterUtilizationIndexRFRegisterUtilizationIndex
 Index for connecting register files and register utilization indices in them.
 

Public Member Functions

 UtilizationStats ()
 
virtual ~UtilizationStats ()
 
virtual void calculateForInstruction (const TTAProgram::Instruction &instructionData, const ExecutableInstruction &executionCounts)
 
ClockCycleCount busWrites (const std::string &busName) const
 
ClockCycleCount socketWrites (const std::string &socketName) const
 
ClockCycleCount triggerCount (const std::string &fuName) const
 
ClockCycleCount operationExecutions (const std::string &operationName) const
 
ClockCycleCount operationExecutions (const std::string &fuName, const std::string &operationName) const
 
ClockCycleCount registerReads (const std::string &rfName, int registerIndex) const
 
ClockCycleCount guardRegisterReads (const std::string &rfName, int registerIndex) const
 
ClockCycleCount registerWrites (const std::string &rfName, int registerIndex) const
 
ClockCycleCount FUGuardAccesses (const std::string &fuName, const std::string &fuPort) const
 
FUOperationUtilizationIndex FUGuardAccesses () const
 
int highestUsedRegisterIndex () const
 
- Public Member Functions inherited from SimulationStatisticsCalculator
 SimulationStatisticsCalculator ()
 
virtual ~SimulationStatisticsCalculator ()
 

Private Attributes

ComponentUtilizationIndex sockets_
 Socket write counts.
 
ComponentUtilizationIndex buses_
 Bus write counts.
 
ComponentUtilizationIndex fus_
 Function unit utilizations, i.e., total operation triggerings.
 
ComponentUtilizationIndex operations_
 Operation utilizations (started operations).
 
FUOperationUtilizationIndex fuOperations_
 Index for operation utilizations for each function unit.
 
RFRegisterUtilizationIndex rfAccesses_
 Register read and write data for each register in each register file.
 
RFRegisterUtilizationIndex guardRfAccesses_
 Guard register accesses for each register in a RF.
 
FUOperationUtilizationIndex guardFUAccesses_
 Guard FU port accesses.
 
int highestRegister_
 The highest register index used. This is an uglish way to fetch register access info for sequential simulation.
 

Detailed Description

Calculates processor utilization data from instructions and their execution counts.

Definition at line 50 of file UtilizationStats.hh.

Member Typedef Documentation

◆ ComponentUtilizationIndex

Index for connecting component names to utilization counts.

Definition at line 53 of file UtilizationStats.hh.

◆ FUOperationUtilizationIndex

Index for connecting function unit and operations implemented in them to utilization counts.

Definition at line 62 of file UtilizationStats.hh.

◆ RegisterUtilizationIndex

Index for connecting register indices to utilization counts. The first number in the pair is the count of reads, and the second is the count of writes.

Definition at line 58 of file UtilizationStats.hh.

◆ RFRegisterUtilizationIndex

Index for connecting register files and register utilization indices in them.

Definition at line 66 of file UtilizationStats.hh.

Constructor & Destructor Documentation

◆ UtilizationStats()

UtilizationStats::UtilizationStats ( )

Constructor.

Definition at line 54 of file UtilizationStats.cc.

54 : highestRegister_(-1) {
55}
int highestRegister_
The highest register index used. This is an uglish way to fetch register access info for sequential s...

◆ ~UtilizationStats()

UtilizationStats::~UtilizationStats ( )
virtual

Destructor.

Definition at line 60 of file UtilizationStats.cc.

60 {
61}

Member Function Documentation

◆ busWrites()

ClockCycleCount UtilizationStats::busWrites ( const std::string &  busName) const

Returns the count of writes to the given bus.

Parameters
busNameThe name of the bus.
Returns
The count of writes.

Definition at line 192 of file UtilizationStats.cc.

192 {
193 if (MapTools::containsKey(buses_, busName))
195 else
196 return 0;
197}
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)
static bool containsKey(const MapType &aMap, const KeyType &aKey)
ComponentUtilizationIndex buses_
Bus write counts.

References buses_, MapTools::containsKey(), and MapTools::keyForValue().

Referenced by ProximBusDetailsCmd::Do(), InfoProcCommand::execute(), SimulatorFrontend::finishSimulation(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

◆ calculateForInstruction()

void UtilizationStats::calculateForInstruction ( const TTAProgram::Instruction instructionData,
const ExecutableInstruction executionCounts 
)
virtual

Accumulates the utilization counts for each machine part used by the instruction.

Note
This function assumes that moves in Instruction and ExecutableInstruction are in same order.
Parameters
instructionDataThe instruction.
executionCountsExecution counts of the instruction.

Implements SimulationStatisticsCalculator.

Definition at line 74 of file UtilizationStats.cc.

76 {
77
78 // used to make sure output socket utilizations are computed only
79 // maximum once per instruction, even though the socket is read by
80 // multiple buses
81 hash_set<const char*> alreadyRegisteredOutputSockets;
82
83 for (int i = 0; i < instructionData.moveCount(); ++i) {
84 const TTAProgram::Move& move = instructionData.move(i);
85 const ClockCycleCount execCount =
86 executionCounts.moveExecutionCount(i);
87
88 // it depends on GCU implementation whether immediate jumps are
89 // redirected through bus and sockets or not, let's assume they
90 // are, as they are in current CU implementations, according to Teemu
91 buses_[move.bus().name()] += execCount;
92
93 // socket utilizations
94 if (!move.source().isImmediate() &&
95 move.sourceSocket().name() != move.destinationSocket().name() &&
96 alreadyRegisteredOutputSockets.find(
97 move.sourceSocket().name().c_str()) ==
98 alreadyRegisteredOutputSockets.end()) {
99
100 sockets_[move.sourceSocket().name()] += execCount;
101 alreadyRegisteredOutputSockets.insert(
102 move.sourceSocket().name().c_str());
103 }
104 sockets_[move.destinationSocket().name()] += execCount;
105
106 // operation utilizations
107 if (move.destination().isFUPort() &&
108 dynamic_cast<const TTAMachine::BaseFUPort&>(
109 move.destination().port()).isTriggering()) {
110 const std::string operationUpper =
112 move.destination().operation().name());
113 const std::string fuName =
114 move.destination().functionUnit().name();
115 fus_[fuName] += execCount;
116 operations_[operationUpper] += execCount;
117 fuOperations_[fuName][operationUpper] += execCount;
118 }
119
120 // register reads
121 if (move.source().isGPR()) {
122 const std::string rfName = move.source().registerFile().name();
123 const int regIndex = move.source().index();
124 if (regIndex > highestRegister_) {
125 highestRegister_ = regIndex;
126 }
127 rfAccesses_[rfName][regIndex].first =
128 registerReads(rfName, regIndex) + execCount;
129 }
130
131 // guarded moves
132 if (!move.isUnconditional()) {
133 // RF reads
134 if (dynamic_cast<const TTAMachine::RegisterGuard*>(
135 &move.guard().guard())) {
136 const TTAMachine::RegisterGuard& moveGuard =
137 dynamic_cast<const TTAMachine::RegisterGuard&>(
138 move.guard().guard());
139
140 const std::string rfName = moveGuard.registerFile()->name();
141 const int regIndex = moveGuard.registerIndex();
142 if (regIndex > highestRegister_)
143 highestRegister_ = regIndex;
144
145 guardRfAccesses_[rfName][regIndex].first =
146 guardRegisterReads(rfName, regIndex) + execCount;
147 } else { // FU Port reads
148 if (dynamic_cast<const TTAMachine::PortGuard*>(
149 &move.guard().guard())) {
150 const TTAMachine::PortGuard& moveGuard =
151 dynamic_cast<const TTAMachine::PortGuard&>(
152 move.guard().guard());
153
154 const TTAMachine::FUPort& port = *moveGuard.port();
155 const std::string fuName = port.parentUnit()->name();
156 guardFUAccesses_[fuName][port.name()] += execCount;
157 }
158 }
159 }
160
161 // immediate register reads
162 if (move.source().isImmediateRegister()) {
163 const std::string iuName = move.source().immediateUnit().name();
164 const int regIndex = move.source().index();
165 rfAccesses_[iuName][regIndex].first =
166 registerReads(iuName, regIndex) + execCount;
167 if (regIndex > highestRegister_)
168 highestRegister_ = regIndex;
169 }
170
171 // register writes
172 if (move.destination().isGPR()) {
173 const std::string rfName =
174 move.destination().registerFile().name();
175 const int regIndex = move.destination().index();
176 if (regIndex > highestRegister_) {
177 highestRegister_ = regIndex;
178 }
179 rfAccesses_[rfName][regIndex].second =
180 registerWrites(rfName, regIndex) + execCount;
181 }
182 }
183}
CycleCount ClockCycleCount
Alias for ClockCycleCount.
ClockCycleCount moveExecutionCount(std::size_t moveIndex) const
virtual TCEString name() const
Definition Operation.cc:93
static std::string stringToUpper(const std::string &source)
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
virtual bool isTriggering() const =0
virtual TCEString name() const
FUPort * port() const
virtual std::string name() const
Definition Port.cc:141
const RegisterFile * registerFile() const
Move & move(int i) const
const TTAMachine::Guard & guard() const
Definition MoveGuard.cc:86
TTAMachine::Socket & destinationSocket() const
Definition Move.cc:388
MoveGuard & guard() const
Definition Move.cc:345
TTAMachine::Socket & sourceSocket() const
Definition Move.cc:393
bool isUnconditional() const
Definition Move.cc:154
Terminal & source() const
Definition Move.cc:302
Terminal & destination() const
Definition Move.cc:323
const TTAMachine::Bus & bus() const
Definition Move.cc:373
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251
virtual int index() const
Definition Terminal.cc:274
virtual Operation & operation() const
Definition Terminal.cc:319
virtual bool isGPR() const
Definition Terminal.cc:107
virtual bool isImmediateRegister() const
Definition Terminal.cc:97
virtual const TTAMachine::Port & port() const
Definition Terminal.cc:378
virtual bool isImmediate() const
Definition Terminal.cc:63
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition Terminal.cc:240
virtual const TTAMachine::RegisterFile & registerFile() const
Definition Terminal.cc:225
virtual bool isFUPort() const
Definition Terminal.cc:118
ComponentUtilizationIndex operations_
Operation utilizations (started operations).
FUOperationUtilizationIndex fuOperations_
Index for operation utilizations for each function unit.
ComponentUtilizationIndex fus_
Function unit utilizations, i.e., total operation triggerings.
ClockCycleCount guardRegisterReads(const std::string &rfName, int registerIndex) const
ClockCycleCount registerReads(const std::string &rfName, int registerIndex) const
RFRegisterUtilizationIndex guardRfAccesses_
Guard register accesses for each register in a RF.
ComponentUtilizationIndex sockets_
Socket write counts.
ClockCycleCount registerWrites(const std::string &rfName, int registerIndex) const
RFRegisterUtilizationIndex rfAccesses_
Register read and write data for each register in each register file.
FUOperationUtilizationIndex guardFUAccesses_
Guard FU port accesses.

References TTAProgram::Move::bus(), buses_, TTAProgram::Move::destination(), TTAProgram::Move::destinationSocket(), TTAProgram::Terminal::functionUnit(), fuOperations_, fus_, TTAProgram::Move::guard(), TTAProgram::MoveGuard::guard(), guardFUAccesses_, guardRegisterReads(), guardRfAccesses_, highestRegister_, TTAProgram::Terminal::immediateUnit(), TTAProgram::Terminal::index(), TTAProgram::Terminal::isFUPort(), TTAProgram::Terminal::isGPR(), TTAProgram::Terminal::isImmediate(), TTAProgram::Terminal::isImmediateRegister(), TTAMachine::BaseFUPort::isTriggering(), TTAProgram::Move::isUnconditional(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), ExecutableInstruction::moveExecutionCount(), TTAMachine::Component::name(), TTAMachine::Port::name(), Operation::name(), TTAProgram::Terminal::operation(), operations_, TTAMachine::BaseFUPort::parentUnit(), TTAMachine::PortGuard::port(), TTAProgram::Terminal::port(), TTAMachine::RegisterGuard::registerFile(), TTAProgram::Terminal::registerFile(), TTAMachine::RegisterGuard::registerIndex(), registerReads(), registerWrites(), rfAccesses_, sockets_, TTAProgram::Move::source(), TTAProgram::Move::sourceSocket(), and StringTools::stringToUpper().

Referenced by CompiledSimUtilizationStats::calculate().

Here is the call graph for this function:

◆ FUGuardAccesses() [1/2]

UtilizationStats::FUOperationUtilizationIndex UtilizationStats::FUGuardAccesses ( ) const

Returns a map containing the FU port guard accesses

Returns
A map containing the FU port guard accesses

Definition at line 355 of file UtilizationStats.cc.

355 {
356 return guardFUAccesses_;
357}

References guardFUAccesses_.

◆ FUGuardAccesses() [2/2]

ClockCycleCount UtilizationStats::FUGuardAccesses ( const std::string &  fuName,
const std::string &  fuPort 
) const

Returns number of reads for a single FU port guard

Parameters
fuNameName of the FU
fuPortName of the FU port
Returns
Number of reads for a single FU port guard

Definition at line 336 of file UtilizationStats.cc.

338 {
339
340 try {
343 guardFUAccesses_, fuName), fuPort);
344 } catch (const KeyNotFound&) {
345 return 0;
346 }
347}

References guardFUAccesses_, and MapTools::keyForValue().

Referenced by InfoProcCommand::execute().

Here is the call graph for this function:

◆ guardRegisterReads()

ClockCycleCount UtilizationStats::guardRegisterReads ( const std::string &  rfName,
int  registerIndex 
) const

Returns the count of times the guarded register was read during simulation.

Parameters
rfNameThe name of the register file.
registerIndexThe index of the register.
Returns
The count of guarded reads.

Definition at line 292 of file UtilizationStats.cc.

294 {
295 try {
296 return
298 std::pair<ClockCycleCount, ClockCycleCount> >(
300 guardRfAccesses_, rfName), registerIndex).first;
301 } catch (const KeyNotFound&) {
302 return 0;
303 }
304}
static ValueType valueForKey(const MapType &aMap, const KeyType &aKey)

References guardRfAccesses_, MapTools::keyForValue(), and MapTools::valueForKey().

Referenced by calculateForInstruction(), and InfoProcCommand::execute().

Here is the call graph for this function:

◆ highestUsedRegisterIndex()

int UtilizationStats::highestUsedRegisterIndex ( ) const

Returns the highest used register index.

This is useful when fetching register access data for sequential simulation.

Returns
The index of the highest index register.

Definition at line 367 of file UtilizationStats.cc.

367 {
368 return highestRegister_;
369}

References highestRegister_.

◆ operationExecutions() [1/2]

ClockCycleCount UtilizationStats::operationExecutions ( const std::string &  fuName,
const std::string &  operationName 
) const

Returns the total count of given operation executions in given FU.

Parameters
fuNameThe name of the function unit.
operationNameThe name of the operation.
Returns
The count of executions.

Definition at line 251 of file UtilizationStats.cc.

252 {
253 try {
256 fuOperations_, fuName), operationName);
257 } catch (const KeyNotFound&) {
258 return 0;
259 }
260}

References fuOperations_, and MapTools::keyForValue().

Here is the call graph for this function:

◆ operationExecutions() [2/2]

ClockCycleCount UtilizationStats::operationExecutions ( const std::string &  operationName) const

Returns the total count of operation executions.

Parameters
operationNameThe name of the operation.
Returns
The count of executions.

Definition at line 234 of file UtilizationStats.cc.

235 {
236 if (MapTools::containsKey(operations_, operationName))
238 operations_, operationName);
239 else
240 return 0;
241}

References MapTools::containsKey(), MapTools::keyForValue(), and operations_.

Referenced by ProximFUDetailsCmd::Do(), InfoProcCommand::execute(), InfoStatsCommand::execute(), and SimulatorFrontend::finishSimulation().

Here is the call graph for this function:

◆ registerReads()

ClockCycleCount UtilizationStats::registerReads ( const std::string &  rfName,
int  registerIndex 
) const

Returns the count of times the given register was read during simulation.

Parameters
rfNameThe name of the register file.
registerIndexThe index of the register.
Returns
The count of reads.

Definition at line 270 of file UtilizationStats.cc.

272 {
273 try {
274 return
276 std::pair<ClockCycleCount, ClockCycleCount> >(
278 rfAccesses_, rfName), registerIndex).first;
279 } catch (const KeyNotFound&) {
280 return 0;
281 }
282}

References MapTools::keyForValue(), rfAccesses_, and MapTools::valueForKey().

Referenced by calculateForInstruction(), ProximIUDetailsCmd::Do(), ProximRFDetailsCmd::Do(), InfoProcCommand::execute(), InfoStatsCommand::execute(), and SimulatorFrontend::finishSimulation().

Here is the call graph for this function:

◆ registerWrites()

ClockCycleCount UtilizationStats::registerWrites ( const std::string &  rfName,
int  registerIndex 
) const

Returns the count of times the given register was written during simulation.

Parameters
rfNameThe name of the register file.
registerIndexThe index of the register.
Returns
The count of writes.

Definition at line 314 of file UtilizationStats.cc.

316 {
317 try {
318 return
320 std::pair<ClockCycleCount, ClockCycleCount> >(
322 rfAccesses_, rfName), registerIndex).second;
323 } catch (const KeyNotFound&) {
324 return 0;
325 }
326}

References MapTools::keyForValue(), rfAccesses_, and MapTools::valueForKey().

Referenced by calculateForInstruction(), ProximIUDetailsCmd::Do(), ProximRFDetailsCmd::Do(), InfoProcCommand::execute(), InfoStatsCommand::execute(), and SimulatorFrontend::finishSimulation().

Here is the call graph for this function:

◆ socketWrites()

ClockCycleCount UtilizationStats::socketWrites ( const std::string &  socketName) const

Returns the count of writes to the given socket.

Parameters
socketNameThe name of the socket.
Returns
The count of writes.

Definition at line 206 of file UtilizationStats.cc.

206 {
207 if (MapTools::containsKey(sockets_, socketName))
209 else
210 return 0;
211}

References MapTools::containsKey(), MapTools::keyForValue(), and sockets_.

Referenced by ProximSocketDetailsCmd::Do(), InfoProcCommand::execute(), SimulatorFrontend::finishSimulation(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

◆ triggerCount()

ClockCycleCount UtilizationStats::triggerCount ( const std::string &  fuName) const

Returns the count of operation triggers in given FU.

Parameters
fuNameThe name of the FU.
Returns
The count of triggers.

Definition at line 220 of file UtilizationStats.cc.

220 {
221 if (MapTools::containsKey(fus_, fuName))
223 else
224 return 0;
225}

References MapTools::containsKey(), fus_, and MapTools::keyForValue().

Referenced by ProximFUDetailsCmd::Do(), InfoProcCommand::execute(), SimulatorFrontend::finishSimulation(), and ProximMachineStateWindow::setUtilizationHighlights().

Here is the call graph for this function:

Member Data Documentation

◆ buses_

ComponentUtilizationIndex UtilizationStats::buses_
private

Bus write counts.

Definition at line 103 of file UtilizationStats.hh.

Referenced by busWrites(), and calculateForInstruction().

◆ fuOperations_

FUOperationUtilizationIndex UtilizationStats::fuOperations_
private

Index for operation utilizations for each function unit.

Definition at line 109 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and operationExecutions().

◆ fus_

ComponentUtilizationIndex UtilizationStats::fus_
private

Function unit utilizations, i.e., total operation triggerings.

Definition at line 105 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and triggerCount().

◆ guardFUAccesses_

FUOperationUtilizationIndex UtilizationStats::guardFUAccesses_
private

Guard FU port accesses.

Definition at line 116 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), FUGuardAccesses(), and FUGuardAccesses().

◆ guardRfAccesses_

RFRegisterUtilizationIndex UtilizationStats::guardRfAccesses_
private

Guard register accesses for each register in a RF.

Definition at line 114 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and guardRegisterReads().

◆ highestRegister_

int UtilizationStats::highestRegister_
private

The highest register index used. This is an uglish way to fetch register access info for sequential simulation.

Definition at line 120 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and highestUsedRegisterIndex().

◆ operations_

ComponentUtilizationIndex UtilizationStats::operations_
private

Operation utilizations (started operations).

Definition at line 107 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and operationExecutions().

◆ rfAccesses_

RFRegisterUtilizationIndex UtilizationStats::rfAccesses_
private

Register read and write data for each register in each register file.

Definition at line 111 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), registerReads(), and registerWrites().

◆ sockets_

ComponentUtilizationIndex UtilizationStats::sockets_
private

Socket write counts.

Definition at line 101 of file UtilizationStats.hh.

Referenced by calculateForInstruction(), and socketWrites().


The documentation for this class was generated from the following files: