OpenASIP
2.0
src
applibs
Scheduler
Algorithms
BFPushAntidepsDown.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 BFPushAntidepsDown.cc
27
*
28
* Definition of BFPushAntidepsDown class.
29
*
30
* Checks antidep successors of a move and tries to reschedule the limiting ones
31
* to later cycle b calling BFPushAntidepDown for it.
32
*
33
* @author Heikki Kultala 2014-2020(heikki.kultala-no.spam-tuni.fi)
34
* @note rating: red
35
*/
36
37
#include "
BFPushAntidepsDown.hh
"
38
#include "
BFPushAntidepDown.hh
"
39
40
#include <list>
41
42
#include "
DataDependenceGraph.hh
"
43
44
//#include "DataDependenceGraph.hh"
45
46
bool
BFPushAntidepsDown::operator()
() {
47
48
DataDependenceGraph::EdgeSet
outEdges =
ddg
().
outEdges
(
adepSource_
);
49
int
newLC =
maxLC_
;
50
51
std::list<BFPushAntidepDown*> rescheds;
52
53
for
(
auto
e: outEdges) {
54
if
((e->edgeReason() ==
DataDependenceEdge::EDGE_REGISTER
||
55
e->edgeReason() ==
DataDependenceEdge::EDGE_RA
) &&
56
e->isFalseDep()) {
57
MoveNode
& aDepHead =
ddg
().
headNode
(*e);
58
if
(!aDepHead.
isScheduled
()) {
59
continue
;
60
}
61
int
cycle = aDepHead.
cycle
();
62
int
lat = 1;
63
if
(e->guardUse()) {
64
lat =
adepSource_
.
guardLatency
();
65
}
66
if
(cycle + lat >
maxLC_
) {
67
continue
;
68
}
69
int
dstLC =
ddg
().
latestCycle
(aDepHead);
70
#ifdef DEBUG_BUBBLEFISH_SCHEDULER
71
std::cerr <<
"\t\tShould rescheduling move at: "
72
<< aDepHead.
toString
() << std::endl;
73
std::cerr <<
"\t\tdstLC: "
<< dstLC << std::endl;
74
#endif
75
if
(dstLC > aDepHead.
cycle
()) {
76
rescheds.push_back(
77
new
BFPushAntidepDown
(
sched_
, aDepHead, lat, newLC));
78
}
79
80
81
int
curLC = dstLC - lat + 1;
82
if
(curLC < newLC) {
83
newLC = curLC;
84
}
85
}
86
}
87
// can we improve the situation at all?
88
if
(newLC <=
oldLC_
) {
89
#ifdef DEBUG_BUBBLEFISH_SCHEDULER
90
std::cerr <<
"newLC: "
<< newLC <<
" old LC: "
<<
oldLC_
<< std::endl;
91
#endif
92
for
(std::list<BFPushAntidepDown*>::iterator i = rescheds.begin();
93
i != rescheds.end();) {
94
BFPushAntidepDown
* bfo = *i;
95
delete
bfo;
96
rescheds.erase(i++);
97
}
98
// assert(rescheds.empty());
99
return
false
;
100
}
else
{
101
#ifdef DEBUG_BUBBLEFISH_SCHEDULER
102
std::cerr <<
"\t\t\tCould improve? newLC: "
<< newLC << std::endl;
103
#endif
104
}
105
106
for
(
auto
i = rescheds.begin(); i != rescheds.end();) {
107
BFPushAntidepDown
* bfo = *i;
108
rescheds.erase(i++);
109
runPostChild
(bfo);
110
}
111
return
!
postChildren_
.empty();
112
}
Reversible::postChildren_
std::stack< Reversible * > postChildren_
Definition:
Reversible.hh:58
BFPushAntidepsDown::operator()
bool operator()()
Definition:
BFPushAntidepsDown.cc:46
MoveNode::toString
std::string toString() const
Definition:
MoveNode.cc:576
BoostGraph::headNode
virtual Node & headNode(const Edge &edge) const
DataDependenceGraph.hh
MoveNode
Definition:
MoveNode.hh:65
DataDependenceEdge::EDGE_REGISTER
@ EDGE_REGISTER
Definition:
DataDependenceEdge.hh:53
BFOptimization::sched_
BF2Scheduler & sched_
Definition:
BFOptimization.hh:103
MoveNode::cycle
int cycle() const
Definition:
MoveNode.cc:421
MoveNode::guardLatency
int guardLatency() const
Definition:
MoveNode.cc:779
BoostGraph< MoveNode, DataDependenceEdge >::EdgeSet
std::set< DataDependenceEdge *, typename DataDependenceEdge ::Comparator > EdgeSet
Definition:
BoostGraph.hh:87
BFPushAntidepsDown::maxLC_
int maxLC_
Definition:
BFPushAntidepsDown.hh:54
BFOptimization::ddg
DataDependenceGraph & ddg()
Definition:
BFOptimization.cc:70
BFPushAntidepsDown.hh
BFPushAntidepDown.hh
BFPushAntidepsDown::adepSource_
MoveNode & adepSource_
Definition:
BFPushAntidepsDown.hh:52
BoostGraph::outEdges
virtual EdgeSet outEdges(const Node &node) const
BFPushAntidepDown
Definition:
BFPushAntidepDown.hh:48
MoveNode::isScheduled
bool isScheduled() const
Definition:
MoveNode.cc:409
Reversible::runPostChild
bool runPostChild(Reversible *preChild)
Definition:
Reversible.cc:139
DataDependenceEdge::EDGE_RA
@ EDGE_RA
Definition:
DataDependenceEdge.hh:57
BFPushAntidepsDown::oldLC_
int oldLC_
Definition:
BFPushAntidepsDown.hh:53
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
Generated by
1.8.17