OpenASIP  2.0
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 More...
 
typedef std::map< ConcurrentRFAccess, ClockCycleCountConcurrentRFAccessIndex
 concurrent accesses and their counts More...
 

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. More...
 

Private Attributes

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

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) {
67  frontend.eventHandler().registerListener(
69  frontend.eventHandler().registerListener(
71 }

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 }

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 {
203  return MapTools::valueForKey<ClockCycleCount>(
204  totalAccesses_, boost::make_tuple(
205  rfName, concurrentWrites, concurrentReads));
206  } catch (const Exception& e) {
207  return 0;
208  }
209 }

References totalAccesses_.

◆ 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 
132  ConcurrentRFAccess key(
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 =
152  frontend_.program().instructionAt(address);
153  if (!instruction.hasConditionalRegisterAccesses())
154  return;
155 
156  accessesInInstruction_.clear();
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 }

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:
InstructionMemory::instructionAtConst
const ExecutableInstruction & instructionAtConst(InstructionAddress address) const
TTAProgram::Program
Definition: Program.hh:63
ExecutableInstruction
Definition: ExecutableInstruction.hh:49
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
SimulatorFrontend::program
const TTAProgram::Program & program() const
Definition: SimulatorFrontend.cc:276
TTAProgram::Instruction::move
Move & move(int i) const
Definition: Instruction.cc:193
ExecutableInstruction::executionCount
ClockCycleCount executionCount() const
Definition: ExecutableInstruction.cc:85
SimulationEventHandler::SE_SIMULATION_STOPPED
@ SE_SIMULATION_STOPPED
Generated after simulation has stopped, temporarily or permantently, and control is being returned to...
Definition: SimulationEventHandler.hh:54
TTAProgram::Terminal::registerFile
virtual const TTAMachine::RegisterFile & registerFile() const
Definition: Terminal.cc:225
TTAProgram::Instruction::hasConditionalRegisterAccesses
bool hasConditionalRegisterAccesses() const
Definition: Instruction.cc:412
RFAccessTracker::ConcurrentRFAccess
boost::tuple< std::string, std::size_t, std::size_t > ConcurrentRFAccess
type to be used as a key for storing concurrent access info
Definition: RFAccessTracker.hh:58
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
RFAccessTracker::accessesInInstruction_
RFAccessIndex accessesInInstruction_
container used in collecting register accesses in an instruction
Definition: RFAccessTracker.hh:93
TTAProgram::Program::instructionAt
Instruction & instructionAt(InstructionAddress address) const
Definition: Program.cc:374
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
Informer::unregisterListener
virtual bool unregisterListener(int event, Listener *listener)
Definition: Informer.cc:104
SimulationEventHandler::SE_CYCLE_END
@ SE_CYCLE_END
Generated before advancing the simulator clock at the end of a simulation cycle.
Definition: SimulationEventHandler.hh:50
RFAccessTracker::instructionExecutions_
const InstructionMemory & instructionExecutions_
used to access instruction execution data
Definition: RFAccessTracker.hh:86
Informer::registerListener
virtual bool registerListener(int event, Listener *listener)
Definition: Informer.cc:87
ExecutableInstruction::moveSquashed
bool moveSquashed(std::size_t moveIndex) const
TTAProgram::Terminal::isGPR
virtual bool isGPR() const
Definition: Terminal.cc:107
TTAProgram::Address::location
InstructionAddress location() const
TTAProgram::Move
Definition: Move.hh:55
Exception
Definition: Exception.hh:54
SimulatorFrontend::lastExecutedInstruction
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const
Definition: SimulatorFrontend.cc:1182
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::Instruction::hasRegisterAccesses
bool hasRegisterAccesses() const
Definition: Instruction.cc:399
RFAccessTracker::frontend_
SimulatorFrontend & frontend_
the simulator frontend used to access simulation data
Definition: RFAccessTracker.hh:84
SimulatorFrontend::eventHandler
SimulationEventHandler & eventHandler()
Definition: SimulatorFrontend.cc:2260
RFAccessTracker::conditionalAccesses_
ConcurrentRFAccessIndex conditionalAccesses_
conditional register file accesses are counted in this container
Definition: RFAccessTracker.hh:88
TTAProgram::Move::source
Terminal & source() const
Definition: Move.cc:302
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
RFAccessTracker::totalAccesses_
ConcurrentRFAccessIndex totalAccesses_
total (conditional + unconditional) register file accesses are counted in this container
Definition: RFAccessTracker.hh:91
TTAProgram::Instruction::moveCount
int moveCount() const
Definition: Instruction.cc:176
TTAProgram::Instruction::address
Address address() const
Definition: Instruction.cc:327