OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
BFLateBypass Class Reference

#include <BFLateBypass.hh>

Inheritance diagram for BFLateBypass:
Inheritance graph
Collaboration diagram for BFLateBypass:
Collaboration graph

Public Member Functions

 BFLateBypass (BF2Scheduler &sched, MoveNode &src, MoveNode &dst, int lc)
 
virtual bool operator() ()
 
virtual void undoOnlyMe ()
 
- 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 Attributes

int originalCycle_
 
MoveNodesrc_
 
MoveNodedst_
 
int lc_
 
const TTAMachine::BusoriginalBus_
 
const TTAMachine::BusprologBus_
 
- Protected Attributes inherited from BFOptimization
BF2Schedulersched_
 
- Protected Attributes inherited from Reversible
std::stack< Reversible * > preChildren_
 
std::stack< Reversible * > postChildren_
 

Additional Inherited Members

- Static Public Member Functions inherited from BFOptimization
static void clearPrologMoves ()
 
static MoveNodegetSisterTrigger (const MoveNode &mn, const TTAMachine::Machine &mach)
 
- 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)
 
- Static Protected Attributes inherited from BFOptimization
static std::map< MoveNode *, MoveNode *, MoveNode::ComparatorprologMoves_
 

Detailed Description

Definition at line 47 of file BFLateBypass.hh.

Constructor & Destructor Documentation

◆ BFLateBypass()

BFLateBypass::BFLateBypass ( BF2Scheduler sched,
MoveNode src,
MoveNode dst,
int  lc 
)
inline

Definition at line 49 of file BFLateBypass.hh.

49 :
50 BFOptimization(sched),
51 src_(src), dst_(dst), lc_(lc), prologBus_(NULL) {}
MoveNode & dst_
MoveNode & src_
const TTAMachine::Bus * prologBus_

Member Function Documentation

◆ operator()()

bool BFLateBypass::operator() ( )
virtual

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

Implements Reversible.

Reimplemented in BFLateBypassGuard.

Definition at line 59 of file BFLateBypass.cc.

59 {
60 // if already has guard operation, cannot have source operation.
61 if (dst_.isGuardOperation()) {
62 return false;
63 }
64
65#ifdef DEBUG_BUBBLEFISH_SCHEDULER
66 std::cerr << "\t\tPerforming late bypass: " << dst_.toString() <<std::endl;
67#else
68#ifdef DEBUG_LOOP_SCHEDULER
69 if (ii() != 0) {
70 std::cerr << "\t\tPerforming late bypass, dst: "
71 << dst_.toString() << std::endl;
72 }
73#endif
74#endif
77 MoveNode* prologMN = ii() ? duplicator().getMoveNode(dst_) : NULL;
78 if (prologMN != NULL) {
79 prologBus_ = &prologMN->move().bus();
80#ifdef DEBUG_BUBBLEFISH_SCHEDULER
81 std::cerr << "\t\t\t\tProlog move: " << prologMN->toString()
82 << std::endl;
83 std::cerr << "\t\t\t\tLate bypass saving prolog bus: "
84 << prologBus_->name() << std::endl;
85#endif
86 }
87
88 bool dstTriggering = dst_.move().isTriggering();
89 // this one did not create the prolog copy so do not remove it here.
90 unassign(dst_, false);
91
92 // Take the predecssors so that they can be notified because their
93 // antideps may change
94 // makes compiling too slow, disabled for now
96
99#ifdef DEBUG_BUBBLEFISH_SCHEDULER
100 std::cerr << "\t\t\tMerge and keep fail!" << std::endl;
101#endif
102 return false;
103 }
104
105 // TODO: this does too much optimizations?
106
107 BFOptimization* sched = NULL;
108 if ((dst_.move().isControlFlowMove() && dstTriggering) ||
109 (ii() != 0 &&
110 static_cast<DataDependenceGraph*>(ddg().rootGraph())->
111 writesJumpGuard(dst_))) {
112 if (lc_ < originalCycle_) {
113#ifdef DEBUG_BUBBLEFISH_SCHEDULER
114 std::cerr << "Late bypass fail: must use originalcycle "
115 "which is too late!!!" << std::endl;
116#endif
117 undo();
118 return false;
119 }
121 } else {
122 sched = new BFScheduleBU(sched_, dst_, lc_, false, false, false);
123 }
124 if ((*sched)()) {
125 // TODO: get this from bypass distance setting?
126 if (dst_.cycle() + 3 < originalCycle_) {
127#ifdef DEBUG_BUBBLEFISH_SCHEDULER
128 std::cerr << "\t\t\tToo long bypass dist, fail late bypass!"
129 << std::endl;
130#endif
131 sched->undo();
132 delete sched;
133 undo();
134 return false;
135 }
136
137 postChildren_.push(sched);
138#ifdef DEBUG_BUBBLEFISH_SCHEDULER
139 std::cerr << "\t\tLate bypass ok: " << dst_.toString() << std::endl;
140#endif
141
142 // now notify antideps sources
143 for (auto i : pred) {
144 mightBeReady(*i);
145 }
146
147 return true;
148 } else {
149#ifdef DEBUG_BUBBLEFISH_SCHEDULER
150 std::cerr << "\t\tLate bypass sched fail.: " << dst_.toString()
151 << std::endl;
152#endif
153 delete sched;
154 undo();
155 return false;
156 }
157}
const TTAMachine::Bus * originalBus_
virtual void mightBeReady(MoveNode &mn)
unsigned int ii() const
BF2Scheduler & sched_
DataDependenceGraph & ddg()
virtual void unassign(MoveNode &mn, bool disposePrologCopy=true)
MoveNodeDuplicator & duplicator() 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 NodeSet predecessors(const Node &node, bool ignoreBackEdges=false, bool ignoreForwardEdges=false) const
std::set< GraphNode *, typename GraphNode::Comparator > NodeSet
Definition Graph.hh:53
MoveNode * getMoveNode(MoveNode &mn)
bool isGuardOperation() const
Definition MoveNode.cc:181
int cycle() const
Definition MoveNode.cc:421
std::string toString() const
Definition MoveNode.cc:576
TTAProgram::Move & move()
bool runPostChild(Reversible *preChild)
std::stack< Reversible * > postChildren_
Definition Reversible.hh:58
virtual void undo()
Definition Reversible.cc:69
virtual TCEString name() const
bool isControlFlowMove() const
Definition Move.cc:233
bool isTriggering() const
Definition Move.cc:284
const TTAMachine::Bus & bus() const
Definition Move.cc:373

References BFOptimization::assign(), TTAProgram::Move::bus(), MoveNode::cycle(), BFOptimization::ddg(), dst_, BFOptimization::duplicator(), MoveNodeDuplicator::getMoveNode(), BFOptimization::ii(), TTAProgram::Move::isControlFlowMove(), MoveNode::isGuardOperation(), TTAProgram::Move::isTriggering(), lc_, BFOptimization::mightBeReady(), MoveNode::move(), TTAMachine::Component::name(), originalBus_, originalCycle_, Reversible::postChildren_, BoostGraph< GraphNode, GraphEdge >::predecessors(), prologBus_, Reversible::runPostChild(), BFOptimization::sched_, src_, MoveNode::toString(), BFOptimization::unassign(), and Reversible::undo().

Here is the call graph for this function:

◆ undoOnlyMe()

void BFLateBypass::undoOnlyMe ( )
virtual

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

Reimplemented from Reversible.

Reimplemented in BFLateBypassGuard.

Definition at line 161 of file BFLateBypass.cc.

161 {
162#ifdef DEBUG_BUBBLEFISH_SCHEDULER
163 std::cerr << "\t\t\tUndoing late bypass: " << dst_.toString() << std::endl;
164#endif
165
166#ifdef DEBUG_BUBBLEFISH_SCHEDULER
167 std::cerr << "\t\t\tReassigning move: " << dst_.toString() <<" to cycle: "
168 << originalCycle_ << " bus: " << originalBus_->name() << std::endl;
169 if (!canAssign(
170 originalCycle_, dst_, originalBus_, NULL, NULL, prologBus_)) {
171 std::cerr << "assign to original cycle fail, cycle: "
172 << originalCycle_ << " movenode: "
173 << dst_.toString() << std::endl;
174 for (int unsigned i = 0; i < dst_.destinationOperationCount(); i++) {
175 std::cerr << "\tDestination op: "
176 << dst_.destinationOperation(i).toString() << std::endl;
177 }
178 ddg().writeToDotFile("late_bypass_undo_fail.dot");
179 assert(false);
180 }
181#endif
183#ifdef DEBUG_BUBBLEFISH_SCHEDULER
184 std::cerr << "\t\tReassigned move:" << dst_.toString() << std::endl;
185#endif
186}
#define assert(condition)
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)
virtual void writeToDotFile(const TCEString &fileName) const
unsigned int destinationOperationCount() const
ProgramOperation & destinationOperation(unsigned int index=0) const
std::string toString() const

References assert, BFOptimization::assign(), BFOptimization::canAssign(), BFOptimization::ddg(), MoveNode::destinationOperation(), MoveNode::destinationOperationCount(), dst_, TTAMachine::Component::name(), originalBus_, originalCycle_, prologBus_, MoveNode::toString(), ProgramOperation::toString(), and GraphBase< GraphNode, GraphEdge >::writeToDotFile().

Here is the call graph for this function:

Member Data Documentation

◆ dst_

MoveNode& BFLateBypass::dst_
protected

◆ lc_

int BFLateBypass::lc_
protected

Definition at line 59 of file BFLateBypass.hh.

Referenced by operator()(), and BFLateBypassGuard::operator()().

◆ originalBus_

const TTAMachine::Bus* BFLateBypass::originalBus_
protected

◆ originalCycle_

int BFLateBypass::originalCycle_
protected

◆ prologBus_

const TTAMachine::Bus* BFLateBypass::prologBus_
protected

Definition at line 61 of file BFLateBypass.hh.

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

◆ src_

MoveNode& BFLateBypass::src_
protected

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