mirror of
https://github.com/The-OpenROAD-Project/OpenSTA.git
synced 2026-09-02 21:39:02 +02:00
PathGroup use BoundedHeap
Signed-off-by: James Cherry <[email protected]>
This commit is contained in:
@@ -60,7 +60,6 @@ public:
|
||||
comp_(comp),
|
||||
min_heap_comp_(comp)
|
||||
{
|
||||
heap_.reserve(max_size);
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
@@ -107,7 +106,12 @@ public:
|
||||
setMaxSize(size_t max_size)
|
||||
{
|
||||
max_size_ = max_size;
|
||||
heap_.reserve(max_size);
|
||||
}
|
||||
|
||||
void
|
||||
reserve(size_t size)
|
||||
{
|
||||
heap_.reserve(size);
|
||||
}
|
||||
|
||||
// Insert an element into the heap.
|
||||
@@ -172,8 +176,6 @@ public:
|
||||
{
|
||||
// Convert heap to sorted vector (best to worst)
|
||||
std::sort_heap(heap_.begin(), heap_.end(), min_heap_comp_);
|
||||
// Reverse to get best first (according to user's comparison)
|
||||
std::reverse(heap_.begin(), heap_.end());
|
||||
std::vector<T> result = std::move(heap_);
|
||||
heap_.clear();
|
||||
return result;
|
||||
@@ -181,11 +183,10 @@ public:
|
||||
|
||||
// Extract all elements sorted from best to worst (const version).
|
||||
// Creates a copy since we can't modify the heap.
|
||||
std::vector<T> extract() const
|
||||
std::vector<T> contents() const
|
||||
{
|
||||
std::vector<T> temp_heap = heap_;
|
||||
std::sort_heap(temp_heap.begin(), temp_heap.end(), min_heap_comp_);
|
||||
std::reverse(temp_heap.begin(), temp_heap.end());
|
||||
return temp_heap;
|
||||
}
|
||||
|
||||
@@ -245,7 +246,7 @@ private:
|
||||
Compare comp_;
|
||||
explicit MinHeapCompare(const Compare& c) : comp_(c) {}
|
||||
bool operator()(const T& a, const T& b) const {
|
||||
return comp_(b, a); // Inverted: worst is at root
|
||||
return comp_(a, b); // comp = less puts largest at root (worst)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+10
-2
@@ -153,9 +153,13 @@ public:
|
||||
|
||||
static bool less(const PathEnd *path_end1,
|
||||
const PathEnd *path_end2,
|
||||
// Compare slack (if constrained), or arrival when false.
|
||||
bool cmp_slack,
|
||||
const StaState *sta);
|
||||
static int cmp(const PathEnd *path_end1,
|
||||
const PathEnd *path_end2,
|
||||
// Compare slack (if constrained), or arrival when false.
|
||||
bool cmp_slack,
|
||||
const StaState *sta);
|
||||
static int cmpSlack(const PathEnd *path_end1,
|
||||
const PathEnd *path_end2,
|
||||
@@ -611,11 +615,13 @@ protected:
|
||||
class PathEndLess
|
||||
{
|
||||
public:
|
||||
PathEndLess(const StaState *sta);
|
||||
PathEndLess(bool cmp_slack,
|
||||
const StaState *sta);
|
||||
bool operator()(const PathEnd *path_end1,
|
||||
const PathEnd *path_end2) const;
|
||||
|
||||
protected:
|
||||
bool cmp_slack_;
|
||||
const StaState *sta_;
|
||||
};
|
||||
|
||||
@@ -623,11 +629,13 @@ protected:
|
||||
class PathEndSlackLess
|
||||
{
|
||||
public:
|
||||
PathEndSlackLess(const StaState *sta);
|
||||
PathEndSlackLess(bool cmp_slack,
|
||||
const StaState *sta);
|
||||
bool operator()(const PathEnd *path_end1,
|
||||
const PathEnd *path_end2) const;
|
||||
|
||||
protected:
|
||||
bool cmp_slack_;
|
||||
const StaState *sta_;
|
||||
};
|
||||
|
||||
|
||||
+10
-14
@@ -29,10 +29,12 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
#include "BoundedHeap.hh"
|
||||
#include "SdcClass.hh"
|
||||
#include "StaState.hh"
|
||||
#include "SearchClass.hh"
|
||||
#include "StringUtil.hh"
|
||||
#include "PathEnd.hh"
|
||||
|
||||
namespace sta {
|
||||
|
||||
@@ -48,7 +50,6 @@ using PathGroupSeq = std::vector<PathGroup*>;
|
||||
class PathGroup
|
||||
{
|
||||
public:
|
||||
~PathGroup();
|
||||
// Path group that compares compare slacks.
|
||||
static PathGroup *makePathGroupArrival(const char *name,
|
||||
int group_path_count,
|
||||
@@ -68,7 +69,7 @@ public:
|
||||
const StaState *sta);
|
||||
const std::string &name() const { return name_; }
|
||||
const MinMax *minMax() const { return min_max_;}
|
||||
const PathEndSeq &pathEnds() const { return path_ends_; }
|
||||
PathEndSeq pathEnds() const;
|
||||
void insert(PathEnd *path_end);
|
||||
// Push group_path_count into path_ends.
|
||||
void pushEnds(PathEndSeq &path_ends);
|
||||
@@ -76,15 +77,14 @@ public:
|
||||
bool saveable(PathEnd *path_end);
|
||||
bool enumMinSlackUnderMin(PathEnd *path_end);
|
||||
int maxPaths() const { return group_path_count_; }
|
||||
PathEndSeq &pathEnds() { return path_ends_; }
|
||||
// This does NOT delete the path ends.
|
||||
void clear();
|
||||
static size_t group_path_count_max;
|
||||
static int group_path_count_max;
|
||||
|
||||
protected:
|
||||
PathGroup(const char *name,
|
||||
size_t group_path_count,
|
||||
size_t endpoint_path_count,
|
||||
int group_path_count,
|
||||
int endpoint_path_count,
|
||||
bool unique_pins,
|
||||
bool unique_edges,
|
||||
float min_slack,
|
||||
@@ -92,21 +92,17 @@ protected:
|
||||
bool cmp_slack,
|
||||
const MinMax *min_max,
|
||||
const StaState *sta);
|
||||
void ensureSortedMaxPaths();
|
||||
void prune();
|
||||
void sort();
|
||||
|
||||
std::string name_;
|
||||
size_t group_path_count_;
|
||||
size_t endpoint_path_count_;
|
||||
int group_path_count_;
|
||||
int endpoint_path_count_;
|
||||
bool unique_pins_;
|
||||
bool unique_edges_;
|
||||
float slack_min_;
|
||||
float slack_max_;
|
||||
PathEndSeq path_ends_;
|
||||
const MinMax *min_max_;
|
||||
bool compare_slack_;
|
||||
float threshold_;
|
||||
bool cmp_slack_;
|
||||
BoundedHeap<PathEnd*, PathEndLess> heap_;
|
||||
std::mutex lock_;
|
||||
const StaState *sta_;
|
||||
};
|
||||
|
||||
@@ -100,8 +100,8 @@ public:
|
||||
bool unconstrained,
|
||||
const SceneSeq &scenes,
|
||||
const MinMaxAll *min_max,
|
||||
size_t group_path_count,
|
||||
size_t endpoint_path_count,
|
||||
int group_path_count,
|
||||
int endpoint_path_count,
|
||||
bool unique_pins,
|
||||
bool unique_edges,
|
||||
float slack_min,
|
||||
|
||||
Reference in New Issue
Block a user