TaGGroup refcount to reclaim memory

commit cd7169f99ab8b67323c444d4c22d065487e439c1
Author: James Cherry <cherry@parallaxsw.com>
Date:   Sun Aug 31 16:02:03 2025 -0700

    reportArrivals report_tag_index

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

commit 658f842a776bb43eef7dbfd9a08e191c31fb9f11
Author: James Cherry <cherry@parallaxsw.com>
Date:   Mon Aug 25 16:20:50 2025 -0700

    tag group ref count

    Signed-off-by: James Cherry <cherry@parallaxsw.com>

Signed-off-by: James Cherry <cherry@parallaxsw.com>
This commit is contained in:
James Cherry 2025-09-03 15:05:14 -07:00
parent 255988633f
commit e4a1ebf00e
7 changed files with 54 additions and 13 deletions

View File

@ -356,7 +356,8 @@ public:
TagGroup *tagGroup(const Vertex *vertex) const;
TagGroup *tagGroup(TagGroupIndex index) const;
void reportArrivals(Vertex *vertex) const;
void reportArrivals(Vertex *vertex,
bool report_tag_index) const;
Slack wnsSlack(Vertex *vertex,
PathAPIndex path_ap_index);
void levelsChangedBefore();
@ -410,6 +411,7 @@ public:
TagGroupIndex tag_index);
void checkPrevPaths() const;
void deletePaths(Vertex *vertex);
void deleteTagGroup(TagGroup *group);
protected:
void init(StaState *sta);
@ -645,6 +647,7 @@ protected:
// Capacity of tag_groups_.
TagGroupIndex tag_group_capacity_;
std::mutex tag_group_lock_;
std::mutex tag_group_ref_count_lock_;
// Latches data outputs to queue on the next search pass.
VertexSet *pending_latch_outputs_;
std::mutex pending_latch_outputs_lock_;

View File

@ -554,15 +554,20 @@ Search::deleteFilterTagGroups()
for (TagGroupIndex i = 0; i < tag_group_next_; i++) {
TagGroup *group = tag_groups_[i];
if (group
&& group->hasFilterTag()) {
tag_group_set_->erase(group);
tag_groups_[group->index()] = nullptr;
tag_group_free_indices_.push_back(i);
delete group;
}
&& group->hasFilterTag())
deleteTagGroup(group);
}
}
void
Search::deleteTagGroup(TagGroup *group)
{
tag_group_set_->erase(group);
tag_groups_[group->index()] = nullptr;
tag_group_free_indices_.push_back(group->index());
delete group;
}
void
Search::deleteFilterTags()
{
@ -2777,6 +2782,15 @@ Search::setVertexArrivals(Vertex *vertex,
filtered_arrivals_->insert(vertex);
}
}
if (tag_group != prev_tag_group) {
LockGuard lock(tag_group_ref_count_lock_);
tag_group->incrRefCount();
if (prev_tag_group) {
prev_tag_group->decrRefCount();
if (prev_tag_group->refCount() == 0)
deleteTagGroup(prev_tag_group);
}
}
}
}
@ -2819,12 +2833,14 @@ ReportPathLess::operator()(const Path *path1,
}
void
Search::reportArrivals(Vertex *vertex) const
Search::reportArrivals(Vertex *vertex,
bool report_tag_index) const
{
report_->reportLine("Vertex %s", vertex->to_string(this).c_str());
TagGroup *tag_group = tagGroup(vertex);
if (tag_group) {
report_->reportLine("Group %u", tag_group->index());
if (report_tag_index)
report_->reportLine("Group %u", tag_group->index());
std::vector<const Path*> paths;
VertexPathIterator path_iter(vertex, this);
while (path_iter.hasNext()) {
@ -2859,7 +2875,7 @@ Search::reportArrivals(Vertex *vertex) const
path_ap->pathMinMax()->to_string().c_str(),
delayAsString(path->arrival(), this),
req,
tag->to_string(true, false, this).c_str(),
tag->to_string(report_tag_index, false, this).c_str(),
prev_str.c_str());
}
}

View File

@ -264,9 +264,10 @@ report_tag_groups()
}
void
report_tag_arrivals_cmd(Vertex *vertex)
report_tag_arrivals_cmd(Vertex *vertex,
bool report_tag_index)
{
Sta::sta()->search()->reportArrivals(vertex);
Sta::sta()->search()->reportArrivals(vertex, report_tag_index);
}
void

View File

@ -355,7 +355,7 @@ tagCmp(const Tag *tag1,
return tagStateCmp(tag1, tag2);
}
int
bool
tagEqual(const Tag *tag1,
const Tag *tag2)
{

View File

@ -140,6 +140,9 @@ public:
const Tag *tag2) const;
};
bool
tagEqual(const Tag *tag1,
const Tag *tag2);
int
tagCmp(const Tag *tag1,
const Tag *tag2,

View File

@ -44,6 +44,7 @@ TagGroup::TagGroup(TagGroupIndex index,
bool has_loop_tag) :
path_index_map_(path_index_map),
hash_(pathIndexMapHash(path_index_map)),
ref_count_(0),
index_(index),
has_clk_tag_(has_clk_tag),
has_genclk_src_tag_(has_genclk_src_tag),
@ -56,6 +57,7 @@ TagGroup::TagGroup(TagGroupIndex index,
TagGroup::TagGroup(TagGroupBldr *tag_bldr) :
path_index_map_(&tag_bldr->pathIndexMap()),
hash_(pathIndexMapHash(path_index_map_)),
ref_count_(0),
own_path_map_(false)
{
}
@ -66,6 +68,18 @@ TagGroup::~TagGroup()
delete path_index_map_;
}
void
TagGroup::incrRefCount()
{
ref_count_++;
}
void
TagGroup::decrRefCount()
{
ref_count_--;
}
size_t
TagGroup::pathIndexMapHash(PathIndexMap *path_index_map)
{

View File

@ -65,6 +65,9 @@ public:
size_t pathIndex(Tag *tag) const;
PathIndexMap *pathIndexMap() const { return path_index_map_; }
bool hasTag(Tag *tag) const;
void incrRefCount();
void decrRefCount();
int refCount() const { return ref_count_; }
protected:
static size_t pathIndexMapHash(PathIndexMap *path_index_map);
@ -72,6 +75,7 @@ protected:
// tag -> path index
PathIndexMap *path_index_map_;
size_t hash_;
int ref_count_;
unsigned int index_:tag_group_index_bits;
bool has_clk_tag_:1;
bool has_genclk_src_tag_:1;