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

#include <RFAccessTracker.hh>

Inheritance diagram for RFAccessTracker:
Inheritance graph
Collaboration diagram for RFAccessTracker:
Collaboration graph

Public Types

typedef boost::tuple< std::string, std::size_t, std::size_t > ConcurrentRFAccess
 type to be used as a key for storing concurrent access info
 
typedef std::map< ConcurrentRFAccess, ClockCycleCountConcurrentRFAccessIndex
 concurrent accesses and their counts
 

Public Member Functions

 RFAccessTracker (SimulatorFrontend &frontend, const InstructionMemory &instructions)
 
virtual ~RFAccessTracker ()
 
virtual void handleEvent (int event)
 
ClockCycleCount concurrentRegisterFileAccessCount (const std::string &rfName, std::size_t concurrentWrites, std::size_t concurrentReads) const
 
const ConcurrentRFAccessIndexaccessDataBase () const
 
- Public Member Functions inherited from Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void handleEvent ()
 

Private Types

typedef hash_map< const char *, boost::tuple< std::size_t, std::size_t > > RFAccessIndex
 Index for RF accesses in an instruction.
 

Private Attributes

SimulatorFrontendfrontend_
 the simulator frontend used to access simulation data
 
const InstructionMemoryinstructionExecutions_
 used to access instruction execution data
 
ConcurrentRFAccessIndex conditionalAccesses_
 conditional register file accesses are counted in this container
 
ConcurrentRFAccessIndex totalAccesses_
 total (conditional + unconditional) register file accesses are counted in this container
 
RFAccessIndex accessesInInstruction_
 container used in collecting register accesses in an instruction
 

Detailed Description

Tracks concurrent register file accesses.

Definition at line 52 of file RFAccessTracker.hh.

Member Typedef Documentation

◆ ConcurrentRFAccess

typedef boost::tuple< std::string, std::size_t, std::size_t> RFAccessTracker::ConcurrentRFAccess

type to be used as a key for storing concurrent access info

Definition at line 58 of file RFAccessTracker.hh.

◆ ConcurrentRFAccessIndex

concurrent accesses and their counts

Definition at line 61 of file RFAccessTracker.hh.

◆ RFAccessIndex

typedef hash_map< const char*, boost::tuple<std::size_t , std::size_t > > RFAccessTracker::RFAccessIndex
private

Index for RF accesses in an instruction.

Definition at line 82 of file RFAccessTracker.hh.

Constructor & Destructor Documentation

◆ RFAccessTracker()

RFAccessTracker::RFAccessTracker ( SimulatorFrontend frontend,
const InstructionMemory instructions 
)

Constructor.

Parameters
frontendThe SimulationFrontend which is used to access simulation data.
instructionsUsed to fetch instruction execution counts.

Definition at line 63 of file RFAccessTracker.cc.

65 :
66 frontend_(frontend), instructionExecutions_(instructions) {
71}
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
SimulatorFrontend & frontend_
the simulator frontend used to access simulation data
const InstructionMemory & instructionExecutions_
used to access instruction execution data
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
@ SE_SIMULATION_STOPPED
Generated after simulation has stopped, temporarily or permantently, and control is being returned to...
SimulationEventHandler & eventHandler()

References SimulatorFrontend::eventHandler(), Informer::registerListener(), SimulationEventHandler::SE_CYCLE_END, and SimulationEventHandler::SE_SIMULATION_STOPPED.

Here is the call graph for this function:

◆ ~RFAccessTracker()

RFAccessTracker::~RFAccessTracker ( )
virtual

Member Function Documentation

◆ accessDataBase()

const RFAccessTracker::ConcurrentRFAccessIndex & RFAccessTracker::accessDataBase ( ) const

Returns the access data base.

In case statistics are not up-to-date, finalizes the calculation before returning the index.

Returns
The access data base.

Definition at line 220 of file RFAccessTracker.cc.

220 {
221 return totalAccesses_;
222}
ConcurrentRFAccessIndex totalAccesses_
total (conditional + unconditional) register file accesses are counted in this container

References totalAccesses_.

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

◆ concurrentRegisterFileAccessCount()

ClockCycleCount RFAccessTracker::concurrentRegisterFileAccessCount ( const std::string &  rfName,
std::size_t  concurrentWrites,
std::size_t  concurrentReads 
) const

Returns the count of clock cycles in which the given register file was written and read concurrently the given times.

Parameters
rfNameName of the register file.
concurrentWritesCount of concurrent writes.
concurrentReadsCount of concurrent reads.
Returns
The count of cycles in which the given count of concurrent accesses was made to the given register file.

Definition at line 198 of file RFAccessTracker.cc.

201 {
202 try {
204 totalAccesses_, boost::make_tuple(
205 rfName, concurrentWrites, concurrentReads));
206 } catch (const Exception& e) {
207 return 0;
208 }
209}
static KeyType keyForValue(const MapType &aMap, const ValueType &aValue)

References MapTools::keyForValue(), and totalAccesses_.

Here is the call graph for this function:

◆ handleEvent()

void RFAccessTracker::handleEvent ( int  event)
virtual

Counts the concurrent register file accesses of current clock cycle.

Reimplemented from Listener.

Definition at line 87 of file RFAccessTracker.cc.

87 {
88
90
91 // create a final sum stats which includes the conditional and unconditional
92 // executions
93
94 totalAccesses_.clear();
95
97 const TTAProgram::Instruction* currentInstruction =
98 &program.instructionAt(program.startAddress().location());
99 while (currentInstruction !=
101
102 const ExecutableInstruction& execInstruction =
104 currentInstruction->address().location());
105
106 if (!currentInstruction->hasRegisterAccesses() ||
107 currentInstruction->hasConditionalRegisterAccesses() ||
108 execInstruction.executionCount() == 0) {
109 currentInstruction = &program.nextInstruction(*currentInstruction);
110 continue;
111 }
112
113 accessesInInstruction_.clear();
114
115 for (int i = 0; i < currentInstruction->moveCount(); ++i) {
116 const TTAProgram::Move& move = currentInstruction->move(i);
117 if (move.source().isGPR()) {
119 move.source().registerFile().name().c_str()].get<1>();
120 }
121
122 if (move.destination().isGPR()) {
124 move.destination().registerFile().name().c_str()].
125 get<0>();
126 }
127 }
128
129 for (RFAccessIndex::iterator i = accessesInInstruction_.begin();
130 i != accessesInInstruction_.end(); ++i) {
131
133 (*i).first, (*i).second.get<0>(), (*i).second.get<1>());
134 totalAccesses_[key] += execInstruction.executionCount();
135 }
136
137 currentInstruction = &program.nextInstruction(*currentInstruction);
138 }
139
140 // add the access data of the instruction with the conditional accesses
141 ConcurrentRFAccessIndex::iterator i = conditionalAccesses_.begin();
142 for (; i != conditionalAccesses_.end(); ++i) {
143 ConcurrentRFAccess key = (*i).first;
145 }
146
147 } else if (event == SimulationEventHandler::SE_CYCLE_END) {
148
149 const InstructionAddress& address =
151 const TTAProgram::Instruction& instruction =
153 if (!instruction.hasConditionalRegisterAccesses())
154 return;
155
157
158 const ExecutableInstruction& execInstruction =
160
161 for (int i = 0; i < instruction.moveCount(); ++i) {
162 if (execInstruction.moveSquashed(i))
163 continue;
164 const TTAProgram::Move& move = instruction.move(i);
165 if (move.source().isGPR()) {
167 move.source().registerFile().name().c_str()].get<1>();
168 }
169
170 if (move.destination().isGPR()) {
172 move.destination().registerFile().name().c_str()].get<0>();
173 }
174 }
175
176 for (RFAccessIndex::iterator i = accessesInInstruction_.begin();
177 i != accessesInInstruction_.end(); ++i) {
178 ++conditionalAccesses_[boost::make_tuple(
179 (*i).first, (*i).second.get<0>(),
180 (*i).second.get<1>())];
181 }
182 } else {
183 abortWithError("RFAccessTracker received an unknown event.");
184 }
185}
#define abortWithError(message)
UInt32 InstructionAddress
Definition BaseType.hh:175
find Finds info of the inner loops in the program
ClockCycleCount executionCount() const
bool moveSquashed(std::size_t moveIndex) const
const ExecutableInstruction & instructionAtConst(InstructionAddress address) const
boost::tuple< std::string, std::size_t, std::size_t > ConcurrentRFAccess
type to be used as a key for storing concurrent access info
RFAccessIndex accessesInInstruction_
container used in collecting register accesses in an instruction
ConcurrentRFAccessIndex conditionalAccesses_
conditional register file accesses are counted in this container
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const
const TTAProgram::Program & program() const
virtual TCEString name() const
InstructionAddress location() const
Move & move(int i) const
Address address() const
bool hasConditionalRegisterAccesses() const
bool hasRegisterAccesses() const
Terminal & source() const
Definition Move.cc:302
Terminal & destination() const
Definition Move.cc:323
static NullInstruction & instance()
Instruction & instructionAt(InstructionAddress address) const
Definition Program.cc:374
virtual bool isGPR() const
Definition Terminal.cc:107
virtual const TTAMachine::RegisterFile & registerFile() const
Definition Terminal.cc:225

References abortWithError, accessesInInstruction_, TTAProgram::Instruction::address(), conditionalAccesses_, TTAProgram::Move::destination(), ExecutableInstruction::executionCount(), frontend_, TTAProgram::Instruction::hasConditionalRegisterAccesses(), TTAProgram::Instruction::hasRegisterAccesses(), TTAProgram::NullInstruction::instance(), TTAProgram::Program::instructionAt(), InstructionMemory::instructionAtConst(), instructionExecutions_, TTAProgram::Terminal::isGPR(), SimulatorFrontend::lastExecutedInstruction(), TTAProgram::Address::location(), TTAProgram::Instruction::move(), TTAProgram::Instruction::moveCount(), ExecutableInstruction::moveSquashed(), TTAMachine::Component::name(), program, SimulatorFrontend::program(), TTAProgram::Terminal::registerFile(), SimulationEventHandler::SE_CYCLE_END, SimulationEventHandler::SE_SIMULATION_STOPPED, TTAProgram::Move::source(), and totalAccesses_.

Here is the call graph for this function:

Member Data Documentation

◆ accessesInInstruction_

RFAccessIndex RFAccessTracker::accessesInInstruction_
private

container used in collecting register accesses in an instruction

Definition at line 93 of file RFAccessTracker.hh.

Referenced by handleEvent().

◆ conditionalAccesses_

ConcurrentRFAccessIndex RFAccessTracker::conditionalAccesses_
private

conditional register file accesses are counted in this container

Definition at line 88 of file RFAccessTracker.hh.

Referenced by handleEvent().

◆ frontend_

SimulatorFrontend& RFAccessTracker::frontend_
private

the simulator frontend used to access simulation data

Definition at line 84 of file RFAccessTracker.hh.

Referenced by handleEvent(), and ~RFAccessTracker().

◆ instructionExecutions_

const InstructionMemory& RFAccessTracker::instructionExecutions_
private

used to access instruction execution data

Definition at line 86 of file RFAccessTracker.hh.

Referenced by handleEvent().

◆ totalAccesses_

ConcurrentRFAccessIndex RFAccessTracker::totalAccesses_
private

total (conditional + unconditional) register file accesses are counted in this container

Definition at line 91 of file RFAccessTracker.hh.

Referenced by accessDataBase(), concurrentRegisterFileAccessCount(), and handleEvent().


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