@@ -12,6 +12,7 @@ SPDX-License-Identifier: MIT
12
12
#include < functional>
13
13
#include < fstream>
14
14
#include < iostream>
15
+ #include < queue>
15
16
16
17
using namespace vISA ;
17
18
@@ -882,7 +883,7 @@ class QueueBase {
882
883
// The data-dependency graph.
883
884
preDDD& ddd;
884
885
885
- // Registre pressure related data.
886
+ // Register pressure related data.
886
887
RegisterPressure& rp;
887
888
888
889
// Options to customize scheduler.
@@ -920,6 +921,8 @@ class QueueBase {
920
921
if (TheCurrTupleParts == 0 )
921
922
TheCurrTupleLead = nullptr ;
922
923
}
924
+ virtual void push (preNode* N) = 0;
925
+ virtual preNode* pop () = 0;
923
926
924
927
protected:
925
928
// The current (send) tuple lead.
@@ -947,7 +950,7 @@ class SethiUllmanQueue : public QueueBase {
947
950
}
948
951
949
952
// Add a new ready node.
950
- void push (preNode* N)
953
+ void push (preNode* N) override
951
954
{
952
955
// Clustering nodes have been added.
953
956
if (N->isClustered && !N->isClusterLead )
@@ -962,7 +965,7 @@ class SethiUllmanQueue : public QueueBase {
962
965
}
963
966
964
967
// Schedule the top node.
965
- preNode* pop ()
968
+ preNode* pop () override
966
969
{
967
970
return select ();
968
971
}
@@ -1323,37 +1326,44 @@ class LatencyQueue : public QueueBase {
1323
1326
// group will be scheduled for latency.
1324
1327
std::map<G4_INST *, unsigned > GroupInfo;
1325
1328
1326
- // Instrction latency information.
1329
+ // Instruction latency information.
1327
1330
const LatencyTable <
1328
1331
1332
+ // TODO: Try to apply priority queue to SethiUllmanQueue as well.
1333
+ std::priority_queue<preNode*, std::vector<preNode*>, std::function<bool (preNode*, preNode*)>> ReadyList;
1334
+
1329
1335
public:
1330
1336
LatencyQueue (preDDD& ddd, RegisterPressure& rp, SchedConfig config,
1331
1337
const LatencyTable& LT)
1332
1338
: QueueBase(ddd, rp, config)
1333
1339
, LT(LT)
1340
+ , ReadyList([this ](preNode* a, preNode* b){ return compare (a, b);})
1334
1341
{
1335
1342
init ();
1336
1343
}
1337
1344
1338
1345
// Add a new ready node.
1339
- void push (preNode* N)
1346
+ void push (preNode* N) override
1340
1347
{
1341
1348
if (N->getInst () && N->getInst ()->isPseudoKill ())
1342
1349
pseudoKills.push_back (N);
1343
1350
else
1344
- Q. push_back (N);
1351
+ ReadyList. push (N);
1345
1352
}
1346
1353
1347
1354
// Schedule the top node.
1348
- preNode* pop ()
1355
+ preNode* pop () override
1349
1356
{
1350
1357
// Pop all pseudo-kills if any.
1351
1358
if (!pseudoKills.empty ()) {
1352
1359
preNode* N = pseudoKills.back ();
1353
1360
pseudoKills.pop_back ();
1354
1361
return N;
1355
1362
}
1356
- return select ();
1363
+ assert (!ReadyList.empty ());
1364
+ preNode* N = ReadyList.top ();
1365
+ ReadyList.pop ();
1366
+ return N;
1357
1367
}
1358
1368
1359
1369
bool empty () const
@@ -1365,8 +1375,6 @@ class LatencyQueue : public QueueBase {
1365
1375
void init ();
1366
1376
unsigned calculatePriority (preNode *N);
1367
1377
1368
- preNode* select ();
1369
-
1370
1378
// Compare two ready nodes and decide which one should be scheduled first.
1371
1379
// Return true if N2 has a higher priority than N1, false otherwise.
1372
1380
bool compare (preNode* N1, preNode* N2);
@@ -1636,22 +1644,6 @@ unsigned LatencyQueue::calculatePriority(preNode* N)
1636
1644
return std::max (1U , Priority);
1637
1645
}
1638
1646
1639
- preNode* LatencyQueue::select ()
1640
- {
1641
- assert (!Q.empty ());
1642
- auto TopIter = Q.end ();
1643
- for (auto I = Q.begin (), E = Q.end (); I != E; ++I) {
1644
- preNode* N = *I;
1645
- if (TopIter == Q.end () || compare (*TopIter, N))
1646
- TopIter = I;
1647
- }
1648
- assert (TopIter != Q.end ());
1649
- preNode* Top = *TopIter;
1650
- std::swap (*TopIter, Q.back ());
1651
- Q.pop_back ();
1652
- return Top;
1653
- }
1654
-
1655
1647
// Compare two ready nodes and decide which one should be scheduled first.
1656
1648
// Return true if N2 has a higher priority than N1, false otherwise.
1657
1649
bool LatencyQueue::compare (preNode* N1, preNode* N2)
0 commit comments