Skip to content

Commit 214d959

Browse files
committed
rsz: Use utl timer
Signed-off-by: Martin Povišer <[email protected]>
1 parent 8b20b1d commit 214d959

File tree

3 files changed

+15
-33
lines changed

3 files changed

+15
-33
lines changed

src/rsz/src/Rebuffer.cc

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "sta/TimingArc.hh"
4141
#include "sta/Units.hh"
4242
#include "utl/Logger.h"
43+
#include "utl/timer.h"
4344

4445
namespace rsz {
4546

@@ -64,33 +65,6 @@ using BnetSeq = BufferedNetSeq;
6465
using BnetPtr = BufferedNetPtr;
6566
using BnetMetrics = BufferedNet::Metrics;
6667

67-
class ScopedTimer
68-
{
69-
public:
70-
using Clock = std::chrono::steady_clock;
71-
72-
ScopedTimer(Logger* logger, double& accumulator)
73-
: logger_(logger), accumulator_(accumulator)
74-
{
75-
if (logger_->debugCheck(RSZ, "rebuffer", 1)) {
76-
start_ = Clock::now();
77-
}
78-
}
79-
80-
~ScopedTimer()
81-
{
82-
if (logger_->debugCheck(RSZ, "rebuffer", 1)) {
83-
accumulator_
84-
+= std::chrono::duration<double>{Clock::now() - start_}.count();
85-
}
86-
}
87-
88-
private:
89-
Logger* logger_;
90-
double& accumulator_;
91-
std::chrono::time_point<Clock> start_;
92-
};
93-
9468
// Template magic to make it easier to write algorithms descending
9569
// over the buffer tree in the form of lambdas; it allows recursive
9670
// lambda calling and it keeps track of the level number which is important
@@ -679,7 +653,7 @@ BnetPtr Rebuffer::bufferForTiming(const BnetPtr& tree,
679653
return opts1;
680654
}
681655

682-
ScopedTimer timer(logger_, long_wire_stepping_runtime_);
656+
utl::DebugScopedTimer timer(long_wire_stepping_runtime_);
683657
int round = 0;
684658
while (location != node->location()) {
685659
debugPrint(logger_,
@@ -2112,7 +2086,7 @@ void Rebuffer::fullyRebuffer(Pin* user_pin)
21122086
Vertex* drvr = graph_->pinDrvrVertex(drvr_pin);
21132087

21142088
{
2115-
ScopedTimer timer(logger_, sta_runtime);
2089+
utl::DebugScopedTimer timer(sta_runtime);
21162090
search_->findRequireds(drvr->level());
21172091
}
21182092

@@ -2160,7 +2134,7 @@ void Rebuffer::fullyRebuffer(Pin* user_pin)
21602134
BnetPtr timing_tree = unbuffered_tree;
21612135

21622136
{
2163-
ScopedTimer timer(logger_, bft_runtime);
2137+
utl::DebugScopedTimer timer(bft_runtime);
21642138
for (int i = 0; i < 3; i++) {
21652139
timing_tree = bufferForTiming(timing_tree);
21662140
if (!timing_tree) {
@@ -2227,7 +2201,7 @@ void Rebuffer::fullyRebuffer(Pin* user_pin)
22272201

22282202
BnetPtr area_opt_tree = timing_tree;
22292203
{
2230-
ScopedTimer timer(logger_, ra_runtime);
2204+
utl::DebugScopedTimer timer(ra_runtime);
22312205
for (int i = 0; i < 5 && area_opt_tree; i++) {
22322206
area_opt_tree
22332207
= recoverArea(area_opt_tree, target_slack, ((float) (1 + i)) / 5);
@@ -2317,7 +2291,7 @@ void Rebuffer::fullyRebuffer(Pin* user_pin)
23172291
estimate_parasitics_->updateParasitics();
23182292

23192293
{
2320-
ScopedTimer timer(logger_, sta_runtime);
2294+
utl::DebugScopedTimer timer(sta_runtime);
23212295
sta_->findDelays(max_level);
23222296
search_->findArrivals(max_level);
23232297
}

src/utl/include/utl/timer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class DebugScopedTimer : public Timer
4141
const char* group,
4242
int level,
4343
const std::string& msg);
44+
DebugScopedTimer(double& aggregate);
4445
~DebugScopedTimer() override;
4546

4647
private:

src/utl/src/timer.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,16 @@ DebugScopedTimer::DebugScopedTimer(double& aggregate,
6868
{
6969
}
7070

71+
DebugScopedTimer::DebugScopedTimer(double& aggregate)
72+
: Timer(), logger_(nullptr), aggregate_(&aggregate)
73+
{
74+
}
75+
7176
DebugScopedTimer::~DebugScopedTimer()
7277
{
73-
debugPrint(logger_, tool_, group_, level_, msg_, *this);
78+
if (logger_) {
79+
debugPrint(logger_, tool_, group_, level_, msg_, *this);
80+
}
7481
if (aggregate_) {
7582
*aggregate_ += elapsed();
7683
}

0 commit comments

Comments
 (0)