diff --git a/include/sta/Graph.hh b/include/sta/Graph.hh index 1e173361..1ab2b578 100644 --- a/include/sta/Graph.hh +++ b/include/sta/Graph.hh @@ -332,6 +332,7 @@ protected: // These fields are written by multiple threads, so they // cannot share the same word as the following bit fields. uint32_t tag_group_index_; + uint32_t object_idx_; // Each bit corresponds to a different BFS queue. std::atomic bfs_in_queue_; // 8 @@ -343,7 +344,6 @@ protected: // This flag distinguishes the driver and load vertices. bool is_bidirect_drvr_:1; - unsigned object_idx_:VertexTable::idx_bits; // 7 bool is_reg_clk_:1; bool is_disabled_constraint_:1; bool is_gated_clk_enable_:1; diff --git a/include/sta/Search.hh b/include/sta/Search.hh index ccd427d9..a6258e33 100644 --- a/include/sta/Search.hh +++ b/include/sta/Search.hh @@ -421,6 +421,7 @@ protected: DcalcAnalysisPt *dcalc_ap_max); void deleteTags(); void deleteTagsPrev(); + void deleteUnusedTagGroups(); void seedInvalidArrivals(); void seedArrivals(); void findClockVertices(VertexSet &vertices); diff --git a/search/Search.cc b/search/Search.cc index bff6b4c8..82664cae 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -429,8 +429,10 @@ Search::deletePaths(Vertex *vertex) debugPrint(debug_, "search", 4, "delete paths %s", vertex->name(network_)); TagGroup *tag_group = tagGroup(vertex); - if (tag_group) + if (tag_group) { graph_->deletePaths(vertex); + tag_group->decrRefCount(); + } } //////////////////////////////////////////////////////////////// @@ -633,6 +635,16 @@ Search::deleteTagsPrev() tag_groups_prev_.clear(); } +void +Search::deleteUnusedTagGroups() +{ + for (TagGroupIndex i = 0; i < tag_group_next_; i++) { + TagGroup *group = tag_groups_[i]; + if (group && group->refCount() == 0) + deleteTagGroup(group); + } +} + VertexSeq Search::filteredEndpoints() { @@ -1062,6 +1074,7 @@ Search::findArrivals1(Level level) Stats stats(debug_, report_); int arrival_count = arrival_iter_->visitParallel(level, arrival_visitor_); deleteTagsPrev(); + deleteUnusedTagGroups(); stats.report("Find arrivals"); if (arrival_iter_->empty() && invalid_arrivals_->empty()) { @@ -2757,40 +2770,25 @@ Search::setVertexArrivals(Vertex *vertex, TagGroup *prev_tag_group = tagGroup(vertex); Path *prev_paths = graph_->paths(vertex); TagGroup *tag_group = findTagGroup(tag_bldr); - size_t path_count = tag_group->pathCount(); - // Reuse path array if it is the same size. - if (prev_tag_group - && path_count == prev_tag_group->pathCount()) { + if (tag_group == prev_tag_group) { tag_bldr->copyPaths(tag_group, prev_paths); - vertex->setTagGroupIndex(tag_group->index()); - if (tag_group->hasFilterTag()) { - LockGuard lock(filtered_arrivals_lock_); - filtered_arrivals_->insert(vertex); - } requiredInvalid(vertex); } else { if (prev_tag_group) { graph_->deletePaths(vertex); + prev_tag_group->decrRefCount(); requiredInvalid(vertex); } + size_t path_count = tag_group->pathCount(); Path *paths = graph_->makePaths(vertex, path_count); tag_bldr->copyPaths(tag_group, paths); - vertex->setTagGroupIndex(tag_group->index()); - if (tag_group->hasFilterTag()) { - LockGuard lock(filtered_arrivals_lock_); - filtered_arrivals_->insert(vertex); - } - } - if (tag_group != prev_tag_group) { - LockGuard lock(tag_group_lock_); tag_group->incrRefCount(); - if (prev_tag_group) { - prev_tag_group->decrRefCount(); - if (prev_tag_group->refCount() == 0) - deleteTagGroup(prev_tag_group); - } + } + if (tag_group->hasFilterTag()) { + LockGuard lock(filtered_arrivals_lock_); + filtered_arrivals_->insert(vertex); } } } diff --git a/search/Search.i b/search/Search.i index 76338830..416bab51 100644 --- a/search/Search.i +++ b/search/Search.i @@ -252,7 +252,7 @@ vertex_worst_slack_path(Vertex *vertex, } int -tag_group_path_count() +tag_group_count() { return Sta::sta()->tagGroupCount(); } diff --git a/search/TagGroup.hh b/search/TagGroup.hh index 74b073ab..5039bd5e 100644 --- a/search/TagGroup.hh +++ b/search/TagGroup.hh @@ -24,6 +24,8 @@ #pragma once +#include + #include "Vector.hh" #include "Map.hh" #include "Iterator.hh" @@ -75,7 +77,7 @@ protected: // tag -> path index PathIndexMap *path_index_map_; size_t hash_; - int ref_count_; + std::atomic ref_count_; unsigned int index_:tag_group_index_bits; bool has_clk_tag_:1; bool has_genclk_src_tag_:1;