@@ -825,7 +825,8 @@ class SethiUllmanQueue : public QueueBase {
825
825
private:
826
826
// Initialize Sethi-Ullman numbers.
827
827
void init ();
828
-
828
+ // Check if the Tuple restriction is obeyed.
829
+ bool willNotBreakTupleRestriction (preNode *N) const ;
829
830
// Select next ready node to schedule.
830
831
preNode *select ();
831
832
// In clustering mode
@@ -957,17 +958,19 @@ bool SethiUllmanQueue::compare(preNode *N1, preNode *N2) {
957
958
return N1->getID () > N2->getID ();
958
959
}
959
960
960
-
961
+ bool SethiUllmanQueue::willNotBreakTupleRestriction (preNode *N) const {
962
+ return (!N->getInst () || !N->getInst ()->isSend () || !TheCurrTupleLead ||
963
+ (N->getTupleLead () == TheCurrTupleLead));
964
+ };
961
965
962
966
preNode *SethiUllmanQueue::select () {
963
967
vASSERT (!Q.empty ());
964
968
auto TopIter = Q.end ();
965
969
for (auto I = Q.begin (), E = Q.end (); I != E; ++I) {
966
970
preNode *N = *I;
967
971
// If there's a node to be paired, skip send not in pair.
968
- if (N->getInst () && N->getInst ()->isSend ())
969
- if (TheCurrTupleLead && N->getTupleLead () != TheCurrTupleLead)
970
- continue ;
972
+ if (!willNotBreakTupleRestriction (N))
973
+ continue ;
971
974
if (TopIter == Q.end () || compare (*TopIter, *I))
972
975
TopIter = I;
973
976
}
@@ -997,6 +1000,7 @@ void SethiUllmanQueue::formWorkingSet(preNode *seed,
997
1000
W.push_back (seed);
998
1001
return ;
999
1002
}
1003
+
1000
1004
std::vector<preNode *> Cluster;
1001
1005
Cluster.push_back (seed);
1002
1006
preNode *ClusterWait = nullptr ;
@@ -1047,9 +1051,29 @@ void SethiUllmanQueue::formWorkingSet(preNode *seed,
1047
1051
while (idx < Q.size ()) {
1048
1052
preNode *Tmp = Q[idx];
1049
1053
if (std::find (Cluster.begin (), Cluster.end (), Tmp) != Cluster.end ()) {
1050
- W.push_back (Tmp);
1051
- Q[idx] = Q.back ();
1052
- Q.pop_back ();
1054
+ // For send instruction which is not part of TheCurrTupleLead, the send
1055
+ // instruction cannot be inserted into W. Which will be scheduled before
1056
+ // the other parts of TheCurrTupleLead.
1057
+ // Such as in following 4 send instructions, first two and last two send
1058
+ // instructions must be schedule together, cannot interleave between
1059
+ // them.
1060
+ //
1061
+ // sample_l.RGB (M1, 16) 0x0:uw S31 %bss V0626.0 %null.0 V0628.0
1062
+ // CCTuple_1.0 CCTuple_1.64
1063
+ // sample_l.RGB(M5, 16) 0x0 : uw S31 %bss V0627.0 %null.0 V0629.0
1064
+ // CCTuple_2.0 CCTuple_2.64
1065
+ //
1066
+ // sample_l.RGB(M1, 16) 0x0 : uw S31 %bss V0640.0 %null.0 V0642.0
1067
+ // CCTuple_3.0 CCTuple_3.64
1068
+ // sample_l.RGB(M5, 16) 0x0 : uw S31 %bss V0641.0 %null.0 V0643.0
1069
+ // CCTuple_4.0 CCTuple_4.64
1070
+ if (willNotBreakTupleRestriction (Tmp)) {
1071
+ W.push_back (Tmp);
1072
+ Q[idx] = Q.back ();
1073
+ Q.pop_back ();
1074
+ } else {
1075
+ idx++;
1076
+ }
1053
1077
} else
1054
1078
idx++;
1055
1079
}
@@ -1067,7 +1091,7 @@ void SethiUllmanQueue::formWorkingSet(preNode *seed,
1067
1091
Top = Node; // continue search
1068
1092
Searching = true ;
1069
1093
break ;
1070
- } else {
1094
+ } else if ( willNotBreakTupleRestriction (Node)) {
1071
1095
if (Node != seed) {
1072
1096
Q.erase (std::remove (Q.begin (), Q.end (), Node), Q.end ());
1073
1097
Q.push_back (seed);
0 commit comments