Skip to content

Commit f8bd9cd

Browse files
Convert children_ of Cluster to vector to fix non-determinism
Signed-off-by: Ravi Varadarajan <[email protected]>
1 parent 057ae0b commit f8bd9cd

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/mpl2/src/object.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void Cluster::setParent(Cluster* parent)
454454

455455
void Cluster::addChild(Cluster* child)
456456
{
457-
children_.insert(child);
457+
children_.push_back(child);
458458
}
459459

460460
void Cluster::removeChild(const Cluster* child)
@@ -464,7 +464,7 @@ void Cluster::removeChild(const Cluster* child)
464464

465465
void Cluster::addChildren(const std::vector<Cluster*>& children)
466466
{
467-
children_.insert(children.begin(), children.end());
467+
std::copy(children.begin(), children.end(), std::back_inserter(children_));
468468
}
469469

470470
void Cluster::removeChildren()
@@ -477,7 +477,7 @@ Cluster* Cluster::getParent() const
477477
return parent_;
478478
}
479479

480-
std::set<Cluster*> Cluster::getChildren() const
480+
std::vector<Cluster*> Cluster::getChildren() const
481481
{
482482
return children_;
483483
}
@@ -512,7 +512,7 @@ bool Cluster::mergeCluster(Cluster& cluster, bool& delete_flag)
512512
delete_flag = true;
513513
// if current cluster is not a leaf cluster
514514
if (children_.size() > 0) {
515-
children_.insert(&cluster);
515+
children_.push_back(&cluster);
516516
cluster.setParent(this);
517517
delete_flag = false;
518518
}
@@ -1259,17 +1259,17 @@ void SoftMacro::setShapes(
12591259
return;
12601260
}
12611261
area_ = area;
1262+
width_list_.clear();
1263+
height_list_.clear();
12621264
// sort width list based
12631265
height_list_ = width_list;
12641266
std::sort(height_list_.begin(), height_list_.end(), comparePairFirst);
12651267
for (auto& shape : height_list_) {
1266-
const float min_width = shape.first;
1267-
const float max_width = shape.second;
12681268
if (width_list_.size() == 0
1269-
|| min_width > width_list_[width_list_.size() - 1].second) {
1270-
width_list_.push_back(std::pair<float, float>(min_width, max_width));
1271-
} else {
1272-
width_list_[width_list_.size() - 1].second = max_width;
1269+
|| shape.first > width_list_[width_list_.size() - 1].second) {
1270+
width_list_.push_back(shape);
1271+
} else if (shape.second > width_list_[width_list_.size() - 1].second) {
1272+
width_list_[width_list_.size() - 1].second = shape.second;
12731273
}
12741274
}
12751275
height_list_.clear();
@@ -1329,7 +1329,7 @@ float SoftMacro::getHeight() const
13291329

13301330
float SoftMacro::getArea() const
13311331
{
1332-
return area_;
1332+
return area_ > 0.01 ? area_ : 0.0;
13331333
}
13341334

13351335
// Num Macros

src/mpl2/src/object.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class Cluster
233233
void addChildren(const std::vector<Cluster*>& children);
234234
void removeChildren();
235235
Cluster* getParent() const;
236-
std::set<Cluster*> getChildren() const;
236+
std::vector<Cluster*> getChildren() const;
237237

238238
bool isLeaf() const; // if the cluster is a leaf cluster
239239
bool mergeCluster(Cluster& cluster,
@@ -307,8 +307,8 @@ class Cluster
307307

308308
// Each cluster is a node in the physical hierarchy tree
309309
// Thus we need to define related to parent and children pointers
310-
Cluster* parent_ = nullptr; // parent of current cluster
311-
std::set<Cluster*> children_; // children of current cluster
310+
Cluster* parent_ = nullptr; // parent of current cluster
311+
std::vector<Cluster*> children_; // children of current cluster
312312

313313
// macro tilings for hard macros
314314
std::vector<std::pair<float, float>> macro_tilings_; // <width, height>

0 commit comments

Comments
 (0)