@@ -614,7 +614,7 @@ class ExtTSPImpl {
614
614
void initialize (const ArrayRef<uint64_t > &NodeSizes,
615
615
const ArrayRef<uint64_t > &NodeCounts,
616
616
const ArrayRef<EdgeCount> &EdgeCounts) {
617
- // Initialize nodes
617
+ // Initialize nodes.
618
618
AllNodes.reserve (NumNodes);
619
619
for (uint64_t Idx = 0 ; Idx < NumNodes; Idx++) {
620
620
uint64_t Size = std::max<uint64_t >(NodeSizes[Idx], 1ULL );
@@ -625,7 +625,7 @@ class ExtTSPImpl {
625
625
AllNodes.emplace_back (Idx, Size , ExecutionCount);
626
626
}
627
627
628
- // Initialize jumps between nodes
628
+ // Initialize jumps between the nodes.
629
629
SuccNodes.resize (NumNodes);
630
630
PredNodes.resize (NumNodes);
631
631
std::vector<uint64_t > OutDegree (NumNodes, 0 );
@@ -644,6 +644,9 @@ class ExtTSPImpl {
644
644
AllJumps.emplace_back (&PredNode, &SuccNode, Edge.count );
645
645
SuccNode.InJumps .push_back (&AllJumps.back ());
646
646
PredNode.OutJumps .push_back (&AllJumps.back ());
647
+ // Adjust execution counts.
648
+ PredNode.ExecutionCount = std::max (PredNode.ExecutionCount , Edge.count );
649
+ SuccNode.ExecutionCount = std::max (SuccNode.ExecutionCount , Edge.count );
647
650
}
648
651
}
649
652
for (JumpT &Jump : AllJumps) {
@@ -667,6 +670,7 @@ class ExtTSPImpl {
667
670
AllEdges.reserve (AllJumps.size ());
668
671
for (NodeT &PredNode : AllNodes) {
669
672
for (JumpT *Jump : PredNode.OutJumps ) {
673
+ assert (Jump->ExecutionCount > 0 && " incorrectly initialized jump" );
670
674
NodeT *SuccNode = Jump->Target ;
671
675
ChainEdge *CurEdge = PredNode.CurChain ->getEdge (SuccNode->CurChain );
672
676
// This edge is already present in the graph.
@@ -760,13 +764,13 @@ class ExtTSPImpl {
760
764
// Skip the merge if the ratio between the densities exceeds
761
765
// MaxMergeDensityRatio. Smaller values of the option result in fewer
762
766
// merges, and hence, more chains.
763
- auto ChainPredDensity = ChainPred->density ();
764
- auto ChainSuccDensity = ChainSucc->density ();
765
- auto [minDensity, maxDensity] =
766
- std::minmax (ChainPredDensity, ChainSuccDensity);
767
- assert (minDensity > 0.0 && maxDensity > 0.0 &&
767
+ const double ChainPredDensity = ChainPred->density ();
768
+ const double ChainSuccDensity = ChainSucc->density ();
769
+ assert (ChainPredDensity > 0.0 && ChainSuccDensity > 0.0 &&
768
770
" incorrectly computed chain densities" );
769
- const double Ratio = maxDensity / minDensity;
771
+ auto [MinDensity, MaxDensity] =
772
+ std::minmax (ChainPredDensity, ChainSuccDensity);
773
+ const double Ratio = MaxDensity / MinDensity;
770
774
if (Ratio > MaxMergeDensityRatio)
771
775
continue ;
772
776
@@ -1084,6 +1088,9 @@ class CDSortImpl {
1084
1088
AllJumps.back ().Offset = EdgeOffsets[I];
1085
1089
SuccNode.InJumps .push_back (&AllJumps.back ());
1086
1090
PredNode.OutJumps .push_back (&AllJumps.back ());
1091
+ // Adjust execution counts.
1092
+ PredNode.ExecutionCount = std::max (PredNode.ExecutionCount , Count);
1093
+ SuccNode.ExecutionCount = std::max (SuccNode.ExecutionCount , Count);
1087
1094
}
1088
1095
}
1089
1096
@@ -1104,13 +1111,13 @@ class CDSortImpl {
1104
1111
for (JumpT *Jump : PredNode.OutJumps ) {
1105
1112
NodeT *SuccNode = Jump->Target ;
1106
1113
ChainEdge *CurEdge = PredNode.CurChain ->getEdge (SuccNode->CurChain );
1107
- // this edge is already present in the graph.
1114
+ // This edge is already present in the graph.
1108
1115
if (CurEdge != nullptr ) {
1109
1116
assert (SuccNode->CurChain ->getEdge (PredNode.CurChain ) != nullptr );
1110
1117
CurEdge->appendJump (Jump);
1111
1118
continue ;
1112
1119
}
1113
- // this is a new edge.
1120
+ // This is a new edge.
1114
1121
AllEdges.emplace_back (Jump);
1115
1122
PredNode.CurChain ->addEdge (SuccNode->CurChain , &AllEdges.back ());
1116
1123
SuccNode->CurChain ->addEdge (PredNode.CurChain , &AllEdges.back ());
0 commit comments