My Project
Classes | Public Member Functions | List of all members
Dataflow::BasicBlockGraph Class Reference

#include <DFnetlist.h>

Public Member Functions

 BasicBlockGraph ()
 Constructor.
 
void clear ()
 Initializes the BB graph (empty).
 
int numBasicBlocks () const
 
int numArcs () const
 
bool empty () const
 
bbID createBasicBlock ()
 Adds a new BB to the BB graph. More...
 
void setEntryBasicBlock (bbID bb)
 Defines the entry BB. More...
 
bbID getEntryBasicBlock () const
 
setBBs & getExitBasicBlocks ()
 
void addExitBasicBlock (bbID bb)
 
bool isEntryBasicBlock (bbID bb)
 
bool isExitBasicBlock (bbID bb)
 
bbArcID findArc (bbID src, bbID dst) const
 Returns the arc between two BBs. More...
 
bbArcID findOrAddArc (bbID src, bbID dst, double freq=0)
 Creates an arc between two BBs (if it did not exist) More...
 
bbID getSrcBB (bbArcID arc) const
 Returns the src BB of an arc. More...
 
bbID getDstBB (bbArcID arc) const
 Returns the dst BB of an arc. More...
 
void setProbability (bbArcID arc, double prob)
 Defines the probability of an arc. More...
 
double getProbability (bbArcID arc) const
 Returns the probability of an arc. More...
 
void setFrequencyArc (bbArcID arc, double freq)
 
double getFrequencyArc (bbArcID arc) const
 
bool calculateBackArcs ()
 Calculates the back edges using a DFS traversal from the entry basic block. More...
 
void setBackArc (bbArcID arc, bool back=true)
 Defines whether an arc is forward or backward. More...
 
bool isBackArc (bbArcID arc) const
 Checks whether an arc is forward or backward. More...
 
setBBArcs & predecessors (bbID bb)
 Returns the set of predecessor arcs. More...
 
setBBArcs & successors (bbID bb)
 Returns the set of successor arcs. More...
 
void setFrequency (bbID bb, double f)
 Sets de execution frequency of a BB. More...
 
double getFrequency (bbID bb) const
 Returns the execution frequency of a BB. More...
 
void setExecTime (bbID bb, double t)
 Sets the execution time of a BB. More...
 
double getExecTime (bbID bb) const
 Retgurns the execution time of a BB. More...
 
double isEntryBB (bbID bb)
 
double getDFSorder (bbID bb)
 
void setDFSorder (bbID bb, int order)
 
double getSCCnumber (bbID bb)
 
void setSCCnumber (bbID bb, int number)
 
bool calculateBasicBlockFrequencies (double back_prob=0.9)
 If the BB frequencies are already define, nothing is done. Otherwise, the BB frequencies are calculated treating the graph as a Markov chain. It considers that the frequency of the entry point is 1. If the probabilities of the arcs are not defined, some default values are set, considering that back arcs have a higher probability. More...
 
double extractBasicBlockCycles (double coverage=-1.0)
 Extracts a set of Basic Block cycles that maximizes the covered execution time. More...
 
void DFS ()
 
void computeSCC ()
 
void setDSUnumberArc (bbArcID arc, int number)
 
void addMGnumber (bbArcID arc, int number)
 
int getDSUnumberArc (bbArcID arc)
 
vector< int > & getMGnumbers (bbArcID arc)
 
std::vector< bbID > & getBlocksInCycle (int cycle_number)
 
int getCycleNum ()
 

Detailed Description

Author
Jordi Cortadella
Date
30/08/18

Member Function Documentation

◆ calculateBackArcs()

bool BasicBlockGraph::calculateBackArcs ( )

Calculates the back edges using a DFS traversal from the entry basic block.

Returns
True if successful, and false otherwise (e.g., entry not defined).

◆ calculateBasicBlockFrequencies()

bool BasicBlockGraph::calculateBasicBlockFrequencies ( double  back_prob = 0.9)

If the BB frequencies are already define, nothing is done. Otherwise, the BB frequencies are calculated treating the graph as a Markov chain. It considers that the frequency of the entry point is 1. If the probabilities of the arcs are not defined, some default values are set, considering that back arcs have a higher probability.

Parameters
back_probThe default probablity of back arcs in case the probabilities of the arcs are not defined.
Returns
True if successful, and false if some error occurred.

◆ createBasicBlock()

bbID Dataflow::BasicBlockGraph::createBasicBlock ( )
inline

Adds a new BB to the BB graph.

Returns
The id of the BB.
Note
the IDs start from 1, blocks that don't belong in any basic block have ID 0.

◆ empty()

bool Dataflow::BasicBlockGraph::empty ( ) const
inline
Returns
True if the BB graph is empty, and false otherwise.

◆ extractBasicBlockCycles()

double BasicBlockGraph::extractBasicBlockCycles ( double  coverage = -1.0)

Extracts a set of Basic Block cycles that maximizes the covered execution time.

Parameters
coverageTarget coverage for the cycles (0 <= coverage <= 1). If coverage is negative, only one cycle is extracted (the one with max execution time).
Returns
The ratio of covered execution time (between 0 and 1).

◆ findArc()

bbArcID BasicBlockGraph::findArc ( bbID  src,
bbID  dst 
) const

Returns the arc between two BBs.

Parameters
srcId of the first block.
dstId of the second block.
Returns
Id of the arc. In case it does not exist, it returns invalidDataflowID.

◆ findOrAddArc()

bbArcID BasicBlockGraph::findOrAddArc ( bbID  src,
bbID  dst,
double  freq = 0 
)

Creates an arc between two BBs (if it did not exist)

Parameters
srcId of the first block.
dstId of the second block.
Returns
Id of the arc.

◆ getDstBB()

bbID Dataflow::BasicBlockGraph::getDstBB ( bbArcID  arc) const
inline

Returns the dst BB of an arc.

Parameters
arcId of the arc.
Returns
The id of the BB.

◆ getEntryBasicBlock()

bbID Dataflow::BasicBlockGraph::getEntryBasicBlock ( ) const
inline
Returns
The entry Basic Block

◆ getExecTime()

double Dataflow::BasicBlockGraph::getExecTime ( bbID  bb) const
inline

Retgurns the execution time of a BB.

Parameters
bbThe id of the BB.
Returns
The execution time.

◆ getFrequency()

double Dataflow::BasicBlockGraph::getFrequency ( bbID  bb) const
inline

Returns the execution frequency of a BB.

Parameters
bbThe id of the BB.
Returns
The execution frequency of the BB.

◆ getProbability()

double Dataflow::BasicBlockGraph::getProbability ( bbArcID  arc) const
inline

Returns the probability of an arc.

Parameters
arcId of the arc.
Returns
The probability of the arc.

◆ getSrcBB()

bbID Dataflow::BasicBlockGraph::getSrcBB ( bbArcID  arc) const
inline

Returns the src BB of an arc.

Parameters
arcId of the arc.
Returns
The id of the BB.

◆ isBackArc()

bool Dataflow::BasicBlockGraph::isBackArc ( bbArcID  arc) const
inline

Checks whether an arc is forward or backward.

Parameters
arcId of the arc.
Returns
True if backward, false if forward.

◆ numArcs()

int Dataflow::BasicBlockGraph::numArcs ( ) const
inline
Returns
The number of Arcs

◆ numBasicBlocks()

int Dataflow::BasicBlockGraph::numBasicBlocks ( ) const
inline
Returns
The number of Basic Blocks

◆ predecessors()

setBBArcs& Dataflow::BasicBlockGraph::predecessors ( bbID  bb)
inline

Returns the set of predecessor arcs.

Parameters
bbId of the BB.
Returns
The set of predecessor arcs.

◆ setBackArc()

void Dataflow::BasicBlockGraph::setBackArc ( bbArcID  arc,
bool  back = true 
)
inline

Defines whether an arc is forward or backward.

Parameters
arcId of the arc.
backTrue if backward, false if forward.

◆ setEntryBasicBlock()

void Dataflow::BasicBlockGraph::setEntryBasicBlock ( bbID  bb)
inline

Defines the entry BB.

Parameters
bbId of the entry BB.

◆ setExecTime()

void Dataflow::BasicBlockGraph::setExecTime ( bbID  bb,
double  t 
)
inline

Sets the execution time of a BB.

Parameters
bbThe id of the BB.
eThe execution time.

◆ setFrequency()

void Dataflow::BasicBlockGraph::setFrequency ( bbID  bb,
double  f 
)
inline

Sets de execution frequency of a BB.

Parameters
bbId of the BB.
fExecution frequency.

◆ setProbability()

void Dataflow::BasicBlockGraph::setProbability ( bbArcID  arc,
double  prob 
)
inline

Defines the probability of an arc.

Parameters
arcId of the arc.
probProbability of the arc.

◆ successors()

setBBArcs& Dataflow::BasicBlockGraph::successors ( bbID  bb)
inline

Returns the set of successor arcs.

Parameters
bbId of the BB.
Returns
The set of successor arcs.

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