OpenASIP  2.0
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
BFShareOperands Class Reference

#include <BFShareOperands.hh>

Inheritance diagram for BFShareOperands:
Inheritance graph
Collaboration diagram for BFShareOperands:
Collaboration graph

Public Member Functions

 BFShareOperands (BF2Scheduler &sched, MoveNode &mn, int lc)
 
virtual bool operator() ()
 
virtual bool removedNode ()
 
- Public Member Functions inherited from BFOptimization
 BFOptimization (BF2Scheduler &sched)
 
virtual bool isFinishFront ()
 
virtual void mightBeReady (MoveNode &mn)
 
- Public Member Functions inherited from Reversible
virtual void undo ()
 
virtual ~Reversible ()
 
void deleteChildren (std::stack< Reversible * > &children)
 
int id ()
 
 Reversible ()
 

Protected Member Functions

virtual void undoOnlyMe ()
 
- Protected Member Functions inherited from BFOptimization
DataDependenceGraphddg ()
 
DataDependenceGraphrootDDG ()
 
const DataDependenceGraphddg () const
 
DataDependenceGraphprologDDG ()
 
SimpleResourceManagerrm () const
 
SimpleResourceManagerprologRM () const
 
BUMoveNodeSelectorselector ()
 
const TTAMachine::MachinetargetMachine () const
 
unsigned int ii () const
 
MoveNodeDuplicatorduplicator () const
 
virtual bool assign (int cycle, MoveNode &, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU_=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGuardWriteCycle=false)
 
virtual void unassign (MoveNode &mn, bool disposePrologCopy=true)
 
virtual int rmEC (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1)
 
virtual int rmLC (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1)
 
virtual bool canAssign (int cycle, MoveNode &mn, const TTAMachine::Bus *bus=nullptr, const TTAMachine::FunctionUnit *srcFU=nullptr, const TTAMachine::FunctionUnit *dstFU=nullptr, const TTAMachine::Bus *prologBus=nullptr, int immWriteCycle=-1, int prologImmWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1, bool ignoreGWN=false)
 
bool putAlsoToPrologEpilog (int cycle, MoveNode &mn)
 
void setPrologSrcFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setPrologDstFUAnno (MoveNode &prologMN, MoveNode &loopMN)
 
void setJumpGuard (MoveNode &mn)
 
void unsetJumpGuard (MoveNode &mn)
 
bool needJumpGuard (const MoveNode &mn, int cycle)
 
int jumpGuardAvailableCycle (const MoveNode &mn)
 
bool canBeSpeculated (const Operation &op)
 
bool canBeSpeculated (const MoveNode &mn)
 
bool usePrologMove (const MoveNode &mn)
 
bool canBeScheduled (const MoveNode &mn)
 
const TTAMachine::RegisterFileRFReadPortCountPreventsScheduling (const MoveNode &mn)
 
bool immCountPreventsScheduling (const MoveNode &mn)
 
- Protected Member Functions inherited from Reversible
bool runPreChild (Reversible *preChild)
 
bool runPostChild (Reversible *preChild)
 
bool runChild (std::stack< Reversible * > &children, Reversible *child)
 
bool runChild (Reversible *child, bool pre)
 
void undoAndRemovePreChildren ()
 
void undoAndRemovePostChildren ()
 
void undoAndRemoveChildren (std::stack< Reversible * > &children)
 

Private Attributes

MoveNodemn_
 
int maxCycle_
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 40 of file BFShareOperands.hh.

Constructor & Destructor Documentation

◆ BFShareOperands()

BFShareOperands::BFShareOperands ( BF2Scheduler sched,
MoveNode mn,
int  lc 
)
inline

Definition at line 42 of file BFShareOperands.hh.

42  :
43  BFOptimization(sched), mn_(mn), maxCycle_(lc+6) {
46  if (opts != NULL) {
47  if (opts->operandShareDistance() > -1) {
48  maxCycle_ = lc + opts->operandShareDistance();
49  }
50  }
51  }

References Application::cmdLineOptions(), maxCycle_, and SchedulerCmdLineOptions::operandShareDistance().

Here is the call graph for this function:

Member Function Documentation

◆ operator()()

bool BFShareOperands::operator() ( )
virtual

This performs the operation. Returns true if success, false if fail.

Implements Reversible.

Definition at line 49 of file BFShareOperands.cc.

49  {
50  // TODO: alctually check the guards
51  if (!mn_.move().isUnconditional()) {
52  return false;
53  }
54 
55 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
56  std::cerr << "\t\tShareOperands operator() called for:"
57  << mn_.toString() << std::endl;
58 #endif
59 
62 #ifdef DEBUG_BUBBLEFISH_SCHEDULER
63  std::cerr << "\t\t\tIllegal operand share: " << mn_.toString()
64  << std::endl;
65 #endif
66  return false;
67  }
68 
69  bool didSomething = false;
71  const Operation& op = po.operation();
72  const TTAMachine::FunctionUnit* forcedFU = po.scheduledFU();
73 
75  for (auto i : siblings) {
76  if (!i->isDestinationOperation()) {
77  continue;
78  }
79 
80  if (i->isScheduled()) {
81  if (i->cycle() > maxCycle_) {
82  continue;
83  }
84  // limit operand sharing for reasonable distances
85  // TODO: use the cmd line parameter
86  int ddglc = ddg().latestCycle(mn_, ii(), false, false);
87  if (i->cycle() < ddglc - 5) {
88  continue;
89  }
90 
91  // try share with already scheduled
92  const TTAProgram::Terminal& dt = i->move().destination();
93  if (dt.isFUPort()) {
94  const TTAMachine::FunctionUnit& fu = dt.functionUnit();
95  if (!fu.hasOperation(op.name())) {
96  continue;
97  }
98  const TTAMachine::HWOperation* hwop = fu.operation(op.name());
99  const TTAMachine::FUPort *sharedPort =
100  hwop->port(mn_.move().destination().operationIndex());
101  if (sharedPort != &dt.port()) {
102  continue;
103  }
104  if (dt.isTriggering()) {
105  // TODO: is sibling commutative?
106  continue;
107  }
108  if (forcedFU != NULL) {
109  if (&fu == forcedFU) {
110  MoveNode* trigger =
112  mn_, targetMachine());
113  if (trigger == &mn_) {
114  continue;
115  }
116 
119  if (runPreChild(sows)) {
120  didSomething = true;
121  }
122  }
123  } else {
124  if (fu.hasOperation(op.name())) {
125  if (sched_.isTrigger(fu, mn_)) {
126  // TODO: change commutative
127  continue;
128  }
129 
132  if (runPreChild(sows)) {
133  didSomething = true;
134  }
135  }
136  }
137  }
138  }
139  }
140  return didSomething;
141 }

References BF2Scheduler::currentFront(), BFOptimization::ddg(), TTAProgram::Move::destination(), MoveNode::destinationOperation(), TTAProgram::Terminal::functionUnit(), BFOptimization::getSisterTrigger(), TTAMachine::FunctionUnit::hasOperation(), BFOptimization::ii(), BF2ScheduleFront::illegalOperandShares_, TTAProgram::Terminal::isFUPort(), BF2Scheduler::isTrigger(), TTAProgram::Terminal::isTriggering(), TTAProgram::Move::isUnconditional(), DataDependenceGraph::latestCycle(), maxCycle_, mn_, MoveNode::move(), Operation::name(), TTAMachine::FunctionUnit::operation(), ProgramOperation::operation(), TTAProgram::Terminal::operationIndex(), TTAMachine::HWOperation::port(), TTAProgram::Terminal::port(), DataDependenceGraph::regDepSiblings(), Reversible::runPreChild(), BFOptimization::sched_, ProgramOperation::scheduledFU(), BFOptimization::targetMachine(), and MoveNode::toString().

Here is the call graph for this function:

◆ removedNode()

bool BFShareOperands::removedNode ( )
virtual

Definition at line 145 of file BFShareOperands.cc.

145 { return false; }

◆ undoOnlyMe()

void BFShareOperands::undoOnlyMe ( )
protectedvirtual

Undoes the operations done by this class but not children. This method should be overloaded by most derived classes.

Reimplemented from Reversible.

Definition at line 143 of file BFShareOperands.cc.

143 {}

Member Data Documentation

◆ maxCycle_

int BFShareOperands::maxCycle_
private

Definition at line 59 of file BFShareOperands.hh.

Referenced by BFShareOperands(), and operator()().

◆ mn_

MoveNode& BFShareOperands::mn_
private

Definition at line 58 of file BFShareOperands.hh.

Referenced by operator()().


The documentation for this class was generated from the following files:
ProgramOperation::operation
const Operation & operation() const
Definition: ProgramOperation.cc:590
TTAProgram::Terminal::isFUPort
virtual bool isFUPort() const
Definition: Terminal.cc:118
TTAProgram::Terminal::isTriggering
virtual bool isTriggering() const
Definition: Terminal.cc:298
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
TTAMachine::HWOperation
Definition: HWOperation.hh:52
BFOptimization::ii
unsigned int ii() const
Definition: BFOptimization.cc:85
BoostGraph< MoveNode, DataDependenceEdge >::NodeSet
std::set< MoveNode *, typename MoveNode ::Comparator > NodeSet
Definition: BoostGraph.hh:86
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
BFOptimization::getSisterTrigger
static MoveNode * getSisterTrigger(const MoveNode &mn, const TTAMachine::Machine &mach)
Definition: BFOptimization.cc:848
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
SchedulerCmdLineOptions
Definition: SchedulerCmdLineOptions.hh:45
BFOptimization::targetMachine
const TTAMachine::Machine & targetMachine() const
Definition: BFOptimization.cc:81
BFOptimization::sched_
BF2Scheduler & sched_
Definition: BFOptimization.hh:103
BF2Scheduler::isTrigger
bool isTrigger(const TTAMachine::Unit &unit, MoveNode &mn)
Definition: BF2Scheduler.cc:819
DataDependenceGraph::regDepSiblings
NodeSet regDepSiblings(const MoveNode &mn) const
Definition: DataDependenceGraph.cc:5620
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
TTAMachine::HWOperation::port
virtual FUPort * port(int operand) const
Definition: HWOperation.cc:320
TTAMachine::FUPort
Definition: FUPort.hh:46
TTAProgram::Terminal::operationIndex
virtual int operationIndex() const
Definition: Terminal.cc:364
Application::cmdLineOptions
static CmdLineOptions * cmdLineOptions()
Definition: Application.cc:397
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition: BFOptimization.cc:70
TTAMachine::FunctionUnit::hasOperation
virtual bool hasOperation(const std::string &name) const
Definition: FunctionUnit.cc:330
Operation
Definition: Operation.hh:59
ProgramOperation::scheduledFU
const TTAMachine::FunctionUnit * scheduledFU() const
Definition: ProgramOperation.cc:866
BFOptimization::BFOptimization
BFOptimization(BF2Scheduler &sched)
Definition: BFOptimization.hh:75
BFShareOperands::mn_
MoveNode & mn_
Definition: BFShareOperands.hh:58
TTAProgram::Terminal::functionUnit
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition: Terminal.cc:251
MoveNode::destinationOperation
ProgramOperation & destinationOperation(unsigned int index=0) const
MoveNode::move
TTAProgram::Move & move()
BFShareOperands::maxCycle_
int maxCycle_
Definition: BFShareOperands.hh:59
BF2Scheduler::currentFront
BF2ScheduleFront * currentFront()
Definition: BF2Scheduler.hh:188
Reversible::runPreChild
bool runPreChild(Reversible *preChild)
Definition: Reversible.cc:127
BF2ScheduleFront::illegalOperandShares_
DataDependenceGraph::NodeSet illegalOperandShares_
Definition: BF2ScheduleFront.hh:72
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::Terminal::port
virtual const TTAMachine::Port & port() const
Definition: Terminal.cc:378
TTAMachine::FunctionUnit::operation
virtual HWOperation * operation(const std::string &name) const
Definition: FunctionUnit.cc:363
BFShareOperandWithScheduled
Definition: BFShareOperandWithScheduled.hh:44
SchedulerCmdLineOptions::operandShareDistance
virtual int operandShareDistance() const
Definition: SchedulerCmdLineOptions.cc:336
DataDependenceGraph::latestCycle
int latestCycle(const MoveNode &moveNode, unsigned int ii=UINT_MAX, bool ignoreRegAntideps=false, bool ignoreUnscheduledSuccessors=true, bool ignoreGuards=false, bool ignoreFUDeps=false, bool ignoreSameOperationEdges=false) const
Definition: DataDependenceGraph.cc:543