Skip to content

Commit 423c12c

Browse files
authored
Add local tag caches to PathVisitors (#316)
* Add tag caches to PathVisitor and Search for visit_parallel Signed-off-by: Drew Lewis <[email protected]> * Apply clang-format * Update to avoid Search storing caches and touching Bfs.cc Signed-off-by: Drew Lewis <[email protected]> * Update to avoid Search storing caches and touching Bfs.cc Signed-off-by: Drew Lewis <[email protected]> * Fixed long lines and moved nullptr assignment to constructors Signed-off-by: Drew Lewis <[email protected]> --------- Signed-off-by: Drew Lewis <[email protected]>
1 parent 9f3123c commit 423c12c

File tree

2 files changed

+90
-61
lines changed

2 files changed

+90
-61
lines changed

include/sta/Search.hh

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ public:
256256
Edge *edge,
257257
const RiseFall *to_rf,
258258
const MinMax *min_max,
259-
const PathAnalysisPt *path_ap);
259+
const PathAnalysisPt *path_ap,
260+
TagSet *tag_cache = nullptr);
260261
Tag *thruClkTag(Path *from_path,
261262
Vertex *from_vertex,
262263
Tag *from_tag,
@@ -325,13 +326,14 @@ public:
325326
const RiseFall *to_rf);
326327

327328
Tag *findTag(const RiseFall *rf,
328-
const PathAnalysisPt *path_ap,
329-
const ClkInfo *tag_clk,
330-
bool is_clk,
331-
InputDelay *input_delay,
332-
bool is_segment_start,
333-
ExceptionStateSet *states,
334-
bool own_states);
329+
const PathAnalysisPt *path_ap,
330+
const ClkInfo *tag_clk,
331+
bool is_clk,
332+
InputDelay *input_delay,
333+
bool is_segment_start,
334+
ExceptionStateSet *states,
335+
bool own_states,
336+
TagSet *tag_cache = nullptr);
335337
void reportTags() const;
336338
void reportClkInfos() const;
337339
const ClkInfo *findClkInfo(const ClockEdge *clk_edge,
@@ -515,19 +517,20 @@ protected:
515517
void findAllArrivals(bool thru_latches);
516518
void findArrivals1(Level level);
517519
Tag *mutateTag(Tag *from_tag,
518-
const Pin *from_pin,
519-
const RiseFall *from_rf,
520-
bool from_is_clk,
521-
const ClkInfo *from_clk_info,
522-
const Pin *to_pin,
523-
const RiseFall *to_rf,
524-
bool to_is_clk,
525-
bool to_is_reg_clk,
526-
bool to_is_segment_start,
527-
const ClkInfo *to_clk_info,
528-
InputDelay *to_input_delay,
529-
const MinMax *min_max,
530-
const PathAnalysisPt *path_ap);
520+
const Pin *from_pin,
521+
const RiseFall *from_rf,
522+
bool from_is_clk,
523+
const ClkInfo *from_clk_info,
524+
const Pin *to_pin,
525+
const RiseFall *to_rf,
526+
bool to_is_clk,
527+
bool to_is_reg_clk,
528+
bool to_is_segment_start,
529+
const ClkInfo *to_clk_info,
530+
InputDelay *to_input_delay,
531+
const MinMax *min_max,
532+
const PathAnalysisPt *path_ap,
533+
TagSet *tag_cache = nullptr);
531534
ExceptionPath *exceptionTo(const Path *path,
532535
const Pin *pin,
533536
const RiseFall *rf,
@@ -706,6 +709,7 @@ public:
706709
const StaState *sta);
707710
virtual void visitFaninPaths(Vertex *to_vertex);
708711
virtual void visitFanoutPaths(Vertex *from_vertex);
712+
void initTagCache();
709713

710714
protected:
711715
// Return false to stop visiting.
@@ -752,6 +756,7 @@ protected:
752756
const MinMax *min_max,
753757
const PathAnalysisPt *path_ap) = 0;
754758
SearchPred *pred_;
759+
std::unique_ptr<TagSet> tag_cache_;
755760
};
756761

757762
// Visitor called during forward search to record an

search/Search.cc

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,9 @@ ArrivalVisitor::init(bool always_to_endpoints,
11491149
VertexVisitor *
11501150
ArrivalVisitor::copy() const
11511151
{
1152-
return new ArrivalVisitor(always_to_endpoints_, pred_, this);
1152+
auto visitor = new ArrivalVisitor(always_to_endpoints_, pred_, this);
1153+
visitor->initTagCache();
1154+
return visitor;
11531155
}
11541156

11551157
ArrivalVisitor::~ArrivalVisitor()
@@ -2035,17 +2037,25 @@ Search::inputDelayTag(const Pin *pin,
20352037

20362038
PathVisitor::PathVisitor(const StaState *sta) :
20372039
StaState(sta),
2038-
pred_(sta->search()->evalPred())
2040+
pred_(sta->search()->evalPred()),
2041+
tag_cache_(nullptr)
20392042
{
20402043
}
20412044

20422045
PathVisitor::PathVisitor(SearchPred *pred,
20432046
const StaState *sta) :
20442047
StaState(sta),
2045-
pred_(pred)
2048+
pred_(pred),
2049+
tag_cache_(nullptr)
20462050
{
20472051
}
20482052

2053+
void
2054+
PathVisitor::initTagCache()
2055+
{
2056+
tag_cache_ = std::make_unique<TagSet>(128, TagSet::hasher(this), TagSet::key_equal(this));
2057+
}
2058+
20492059
void
20502060
PathVisitor::visitFaninPaths(Vertex *to_vertex)
20512061
{
@@ -2233,8 +2243,8 @@ PathVisitor::visitFromPath(const Pin *from_pin,
22332243
to_clk_info, to_pin, to_rf, min_max,
22342244
path_ap);
22352245
if (to_tag)
2236-
to_tag = search_->thruTag(to_tag, edge, to_rf, min_max, path_ap);
2237-
from_arrival = search_->clkPathArrival(from_path, from_clk_info,
2246+
to_tag = search_->thruTag(to_tag, edge, to_rf, min_max, path_ap, tag_cache_.get());
2247+
from_arrival = search_->clkPathArrival(from_path, from_clk_info,
22382248
clk_edge, min_max, path_ap);
22392249
to_arrival = from_arrival + arc_delay;
22402250
}
@@ -2249,7 +2259,7 @@ PathVisitor::visitFromPath(const Pin *from_pin,
22492259
latches_->latchOutArrival(from_path, arc, edge, path_ap,
22502260
to_tag, arc_delay, to_arrival);
22512261
if (to_tag)
2252-
to_tag = search_->thruTag(to_tag, edge, to_rf, min_max, path_ap);
2262+
to_tag = search_->thruTag(to_tag, edge, to_rf, min_max, path_ap, tag_cache_.get());
22532263
}
22542264
}
22552265
else if (from_tag->isClock()) {
@@ -2288,7 +2298,7 @@ PathVisitor::visitFromPath(const Pin *from_pin,
22882298
else {
22892299
if (!(sdc_->isPathDelayInternalFromBreak(to_pin)
22902300
|| sdc_->isPathDelayInternalToBreak(from_pin))) {
2291-
to_tag = search_->thruTag(from_tag, edge, to_rf, min_max, path_ap);
2301+
to_tag = search_->thruTag(from_tag, edge, to_rf, min_max, path_ap, tag_cache_.get());
22922302
arc_delay = search_->deratedDelay(from_vertex, arc, edge, false, path_ap);
22932303
if (!delayInf(arc_delay))
22942304
to_arrival = from_arrival + arc_delay;
@@ -2450,10 +2460,11 @@ Search::clkInfoWithCrprClkPath(const ClkInfo *from_clk_info,
24502460
// Return nullptr if the result tag completes a false path.
24512461
Tag *
24522462
Search::thruTag(Tag *from_tag,
2453-
Edge *edge,
2454-
const RiseFall *to_rf,
2455-
const MinMax *min_max,
2456-
const PathAnalysisPt *path_ap)
2463+
Edge *edge,
2464+
const RiseFall *to_rf,
2465+
const MinMax *min_max,
2466+
const PathAnalysisPt *path_ap,
2467+
TagSet *tag_cache)
24572468
{
24582469
const Pin *from_pin = edge->from(graph_)->pin();
24592470
Vertex *to_vertex = edge->to(graph_);
@@ -2462,9 +2473,10 @@ Search::thruTag(Tag *from_tag,
24622473
const ClkInfo *from_clk_info = from_tag->clkInfo();
24632474
bool to_is_reg_clk = to_vertex->isRegClk();
24642475
Tag *to_tag = mutateTag(from_tag, from_pin, from_rf, false, from_clk_info,
2465-
to_pin, to_rf, false, to_is_reg_clk, false,
2466-
// input delay is not propagated.
2467-
from_clk_info, nullptr, min_max, path_ap);
2476+
to_pin, to_rf, false, to_is_reg_clk, false,
2477+
// input delay is not propagated.
2478+
from_clk_info, nullptr, min_max, path_ap,
2479+
tag_cache);
24682480
return to_tag;
24692481
}
24702482

@@ -2617,19 +2629,20 @@ Search::thruClkInfo(Path *from_path,
26172629
// Find the tag for a path going from from_tag thru edge to to_pin.
26182630
Tag *
26192631
Search::mutateTag(Tag *from_tag,
2620-
const Pin *from_pin,
2621-
const RiseFall *from_rf,
2622-
bool from_is_clk,
2623-
const ClkInfo *from_clk_info,
2624-
const Pin *to_pin,
2625-
const RiseFall *to_rf,
2626-
bool to_is_clk,
2627-
bool to_is_reg_clk,
2628-
bool to_is_segment_start,
2629-
const ClkInfo *to_clk_info,
2630-
InputDelay *to_input_delay,
2631-
const MinMax *min_max,
2632-
const PathAnalysisPt *path_ap)
2632+
const Pin *from_pin,
2633+
const RiseFall *from_rf,
2634+
bool from_is_clk,
2635+
const ClkInfo *from_clk_info,
2636+
const Pin *to_pin,
2637+
const RiseFall *to_rf,
2638+
bool to_is_clk,
2639+
bool to_is_reg_clk,
2640+
bool to_is_segment_start,
2641+
const ClkInfo *to_clk_info,
2642+
InputDelay *to_input_delay,
2643+
const MinMax *min_max,
2644+
const PathAnalysisPt *path_ap,
2645+
TagSet *tag_cache)
26332646
{
26342647
ExceptionStateSet *new_states = nullptr;
26352648
ExceptionStateSet *from_states = from_tag->states();
@@ -2713,8 +2726,8 @@ Search::mutateTag(Tag *from_tag,
27132726

27142727
if (new_states)
27152728
return findTag(to_rf, path_ap, to_clk_info, to_is_clk,
2716-
from_tag->inputDelay(), to_is_segment_start,
2717-
new_states, true);
2729+
from_tag->inputDelay(), to_is_segment_start, new_states,
2730+
true, tag_cache);
27182731
else {
27192732
// No state change.
27202733
if (to_clk_info == from_clk_info
@@ -2724,9 +2737,8 @@ Search::mutateTag(Tag *from_tag,
27242737
&& from_tag->inputDelay() == to_input_delay)
27252738
return from_tag;
27262739
else
2727-
return findTag(to_rf, path_ap, to_clk_info, to_is_clk,
2728-
to_input_delay, to_is_segment_start,
2729-
from_states, false);
2740+
return findTag(to_rf, path_ap, to_clk_info, to_is_clk, to_input_delay,
2741+
to_is_segment_start, from_states, false, tag_cache);
27302742
}
27312743
}
27322744

@@ -2972,16 +2984,22 @@ Search::tagCount() const
29722984

29732985
Tag *
29742986
Search::findTag(const RiseFall *rf,
2975-
const PathAnalysisPt *path_ap,
2976-
const ClkInfo *clk_info,
2977-
bool is_clk,
2978-
InputDelay *input_delay,
2979-
bool is_segment_start,
2980-
ExceptionStateSet *states,
2981-
bool own_states)
2987+
const PathAnalysisPt *path_ap,
2988+
const ClkInfo *clk_info,
2989+
bool is_clk,
2990+
InputDelay *input_delay,
2991+
bool is_segment_start,
2992+
ExceptionStateSet *states,
2993+
bool own_states,
2994+
TagSet *tag_cache)
29822995
{
29832996
Tag probe(0, rf->index(), path_ap->index(), clk_info, is_clk, input_delay,
29842997
is_segment_start, states, false, this);
2998+
if (tag_cache) {
2999+
auto tag = tag_cache->findKey(&probe);
3000+
if (tag)
3001+
return tag;
3002+
}
29853003
LockGuard lock(tag_lock_);
29863004
Tag *tag = tag_set_->findKey(&probe);
29873005
if (tag == nullptr) {
@@ -3019,6 +3037,10 @@ Search::findTag(const RiseFall *rf,
30193037
}
30203038
if (own_states)
30213039
delete states;
3040+
3041+
if (tag_cache)
3042+
tag_cache->insert(tag);
3043+
30223044
return tag;
30233045
}
30243046

@@ -3540,7 +3562,9 @@ RequiredVisitor::~RequiredVisitor()
35403562
VertexVisitor *
35413563
RequiredVisitor::copy() const
35423564
{
3543-
return new RequiredVisitor(this);
3565+
auto visitor = new RequiredVisitor(this);
3566+
visitor->initTagCache();
3567+
return visitor;
35443568
}
35453569

35463570
void

0 commit comments

Comments
 (0)