OpenASIP 2.2
Loading...
Searching...
No Matches
BFPushDepsUp.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2014 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24
25/**
26 * @file BFPushDepsUp.cc
27 *
28 * Definition of BFPushDepsUp class
29 *
30 * Tries to reschedule the predecessors of a move into earlier cycle.
31 *
32 * @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
33 * @note rating: red
34 */
35
36#include "BFPushDepsUp.hh"
38#include "BFPushMoveUp.hh"
39#include "BFPushMoveUp2.hh"
40
42
43 if (prefCycle_ < 0) {
44 std::cerr << "push deps up prefcycle negative! "
45 << prefCycle_ << " move: " << mn_.toString() << std::endl;
46 assert(false);
47 }
48#ifdef DEBUG_BUBBLEFISH_SCHEDULER
50 for (int i = 0; i < recurseCounter_*2; i++)
51 std::cerr << "\t";
52 std::cerr << "\tPushing loop deps up: " << mn_.toString() << std::endl;
53#endif
54
55 bool pushed = false;
57 for (auto e : inEdges) {
58 MoveNode& loopDepTail = ddg().tailNode(*e);
59 if (loopDepTail.isScheduled()) {
60 int eLat = ddg().edgeLatency(*e, ii(), &loopDepTail, &mn_);
61 int prefTailCycle = prefCycle_ - eLat;
62#ifdef DEBUG_BUBBLEFISH_SCHEDULER
63 std::cerr << "\t\t\tmy prefcycle is: " << prefCycle_
64 << " latency is: " << eLat
65 << " so preftailcycle is: " << prefTailCycle
66 << std::endl;
67 std::cerr << "\t\t\t\tedge: " <<e->toString() << std::endl;
68#endif
69 if (loopDepTail.cycle() > prefTailCycle) {
70 if (prefTailCycle < 0) {
71#ifdef DEBUG_BUBBLEFISH_SCHEDULER
73#endif
75 return false;
76 }
77 BFOptimization* pushMoveUp;
78 if (loopDepTail.isSourceOperation()) {
79 pushMoveUp =
80 new BFPushMoveUp2(sched_, loopDepTail, prefTailCycle);
81 } else {
82 pushMoveUp =
83 new BFPushMoveUp(sched_, loopDepTail, prefTailCycle);
84 }
85 if (runPreChild(pushMoveUp)) {
86#ifdef DEBUG_BUBBLEFISH_SCHEDULER
87 for (int i = 0; i < recurseCounter_*2; i++)
88 std::cerr << "\t";
89 std::cerr << "\tpushed up succesfully: "
90 << loopDepTail.toString()
91 << " preChildren size: "
92 << preChildren_.size() << std::endl;
93#endif
94 pushed = true;
95 } else {
96#ifdef DEBUG_BUBBLEFISH_SCHEDULER
97 for (int i = 0; i < recurseCounter_*2; i++)
98 std::cerr << "\t";
99 std::cerr << "\t\tpushing up fail: "
100 << loopDepTail.toString()
101 << " preChildren size: "
102 << preChildren_.size() << std::endl;
103#endif
105#ifdef DEBUG_BUBBLEFISH_SCHEDULER
107#endif
108 return false;
109 }
110 }
111 }
112 }
113#ifdef DEBUG_BUBBLEFISH_SCHEDULER
115#endif
116
117 return pushed;
118}
119
#define assert(condition)
unsigned int ii() const
BF2Scheduler & sched_
DataDependenceGraph & ddg()
MoveNode & mn_
bool operator()()
static int recurseCounter_
virtual Node & tailNode(const Edge &edge) const
virtual EdgeSet inEdges(const Node &node) const
int edgeLatency(const DataDependenceEdge &edge, int ii, const MoveNode *tail, const MoveNode *head) const
std::set< GraphEdge *, typename GraphEdge::Comparator > EdgeSet
Definition Graph.hh:54
int cycle() const
Definition MoveNode.cc:421
std::string toString() const
Definition MoveNode.cc:576
bool isSourceOperation() const
Definition MoveNode.cc:168
bool isScheduled() const
Definition MoveNode.cc:409
std::stack< Reversible * > preChildren_
Definition Reversible.hh:57
void undoAndRemovePreChildren()
Definition Reversible.cc:80
bool runPreChild(Reversible *preChild)