Skip to content

Commit 40fdadd

Browse files
Merge pull request #10573 from oharboe/dpl-optmirror-deterministic
dpl: make optimize_mirroring deterministic
2 parents 51850f9 + 817099e commit 40fdadd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/dpl/src/OptMirror.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,16 @@ void OptimizeMirroring::run()
6363
}
6464

6565
// Sort net boxes by net hpwl.
66-
std::ranges::sort(sorted_boxes,
67-
[](NetBox* net_box1, NetBox* net_box2) -> bool {
68-
return net_box1->hpwl() > net_box2->hpwl();
69-
});
66+
std::ranges::sort(
67+
sorted_boxes, [](NetBox* net_box1, NetBox* net_box2) -> bool {
68+
const int64_t hpwl1 = net_box1->hpwl();
69+
const int64_t hpwl2 = net_box2->hpwl();
70+
if (hpwl1 != hpwl2) {
71+
return hpwl1 > hpwl2;
72+
}
73+
// net_box_map_ is unordered; tie-break for stable output.
74+
return net_box1->getNet()->getId() < net_box2->getNet()->getId();
75+
});
7076

7177
std::vector<odb::dbInst*> mirror_candidates
7278
= findMirrorCandidates(sorted_boxes);

0 commit comments

Comments
 (0)