From 9b1dc880f5461ac8d25ebf7824f5781201f21a09 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Tue, 29 Dec 2020 10:33:22 -0800 Subject: [PATCH] rm Debug::print --- dcalc/ArnoldiReduce.cc | 44 +++++++++++++++++++++------------------- dcalc/DmpCeff.cc | 43 +++++++++++++++++++-------------------- dcalc/GraphDelayCalc1.cc | 2 +- graph/Graph.cc | 2 +- include/sta/Debug.hh | 3 --- include/sta/Stats.hh | 5 ++++- sdc/SdcGraph.cc | 2 +- search/Genclks.cc | 2 +- search/Levelize.cc | 2 +- search/PathEnum.cc | 37 +++++++++++++++++---------------- search/PathGroup.cc | 2 +- search/Search.cc | 9 ++++---- search/Sim.cc | 2 +- search/Sta.cc | 4 ++-- util/Debug.cc | 10 --------- util/Stats.cc | 17 +++++++++------- verilog/VerilogReader.cc | 16 +++++++-------- 17 files changed, 99 insertions(+), 103 deletions(-) diff --git a/dcalc/ArnoldiReduce.cc b/dcalc/ArnoldiReduce.cc index 8fa0f43b..e8199509 100644 --- a/dcalc/ArnoldiReduce.cc +++ b/dcalc/ArnoldiReduce.cc @@ -486,16 +486,16 @@ ArnoldiReduce::makeRcmodelFromTs() for (k=0;kts,p-p0, + p->ts, + p-p0, units_->capacitanceUnit()->asString(p->c)); if (p->is_term) - debug_->print(" term%d", p->tindex); + debugPrint1(debug_, "arnoldi", 1, " term %d", p->tindex); if (p->in_edge) - debug_->print(" from T%d,P%ld r=%s", - p->in_edge->from->ts, - p->in_edge->from-p0, - units_->resistanceUnit()->asString(p->r)); - debug_->print("\n"); + debugPrint3(debug_, "arnoldi", 1, " from T%d,P%ld r=%s", + p->in_edge->from->ts, + p->in_edge->from-p0, + units_->resistanceUnit()->asString(p->r)); } for (i=0;icheck("arnoldi", 1)) { - debugPrint1(debug_, "arnoldi", 1, - "tridiagonal reduced matrix, drvr pin %s", - network_->pathName(drvr_pin_)); - debugPrint2(debug_, "arnoldi", 1, "order %d n %d",order,n); + report_->reportLine("tridiagonal reduced matrix, drvr pin %s", + network_->pathName(drvr_pin_)); + report_->reportLine("order %d n %d",order,n); for (h=0;hprint("d[%d] %s", - h, - units_->timeUnit()->asString(d[h])); if (hprint(" e[%d] %s", - h, - units_->timeUnit()->asString(e[h])); - debug_->print("\n"); - debug_->print("U[%d]",h); + report_->reportLine(" d[%d] %s e[%d] %s", + h, + units_->timeUnit()->asString(d[h]), + h, + units_->timeUnit()->asString(e[h])); + + else + report_->reportLine(" d[%d] %s", + h, + units_->timeUnit()->asString(d[h])); + string line = stdstrPrint("U[%d]",h); for (i=0;iprint(" %6.2e",U[h][i]); - debug_->print("\n"); + line += stdstrPrint(" %6.2e",U[h][i]); + report_->reportLine(line); } } } diff --git a/dcalc/DmpCeff.cc b/dcalc/DmpCeff.cc index 34a78bd9..7a61902e 100644 --- a/dcalc/DmpCeff.cc +++ b/dcalc/DmpCeff.cc @@ -462,28 +462,29 @@ void DmpAlg::showX() { for (int i = 0; i < nr_order_; i++) - debug_->print("%4s %12.3e\n", dmp_param_index_strings[i], x_[i]); + report_->reportLine("%4s %12.3e", dmp_param_index_strings[i], x_[i]); } void DmpAlg::showFvec() { for (int i = 0; i < nr_order_; i++) - debug_->print("%4s %12.3e\n", dmp_func_index_strings[i], fvec_[i]); + report_->reportLine("%4s %12.3e", dmp_func_index_strings[i], fvec_[i]); } void DmpAlg::showJacobian() { - debug_->print(" "); + string line = " "; for (int j = 0; j < nr_order_; j++) - debug_->print("%12s", dmp_param_index_strings[j]); - debug_->print("\n"); + line += stdstrPrint("%12s", dmp_param_index_strings[j]); + report_->reportLine(line); + line.clear(); for (int i = 0; i < nr_order_; i++) { - debug_->print("%4s ", dmp_func_index_strings[i]); + line += stdstrPrint("%4s ", dmp_func_index_strings[i]); for (int j = 0; j < nr_order_; j++) - debug_->print("%12.3e ", fjac_[i][j]); - debug_->print("\n"); + line += stdstrPrint("%12.3e ", fjac_[i][j]); + report_->reportLine(line); } } @@ -545,12 +546,10 @@ DmpAlg::dVoDt(double t) void DmpAlg::showVo() { - debug_->print(" t vo(t)\n"); + report_->reportLine(" t vo(t)"); double ub = voCrossingUpperBound(); for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0) - debug_->print(" %g %g\n", t, vo(t)); - // debug_->print(" %.3g %.3g", t-t0_, vo(t)*3); - // debug_->print("\n"); + report_->reportLine(" %g %g", t, vo(t)); } void @@ -658,10 +657,10 @@ DmpAlg::dVlDt(double t) void DmpAlg::showVl() { - debug_->print(" t vl(t)\n"); + report_->reportLine(" t vl(t)"); double ub = vlCrossingUpperBound(); for (double t = t0_; t < t0_ + ub * 2.0; t += ub / 10.0) - debug_->print(" %g %g\n", t, vl(t)); + report_->reportLine(" %g %g", t, vl(t)); } void @@ -669,12 +668,12 @@ DmpAlg::fail(const char *reason) { // Allow only failures to be reported with a unique debug flag. if (debug_->check("dmp_ceff", 1) || debug_->check("dmp_ceff_fail", 1)) - debug_->print("delay_calc: DMP failed - %s c2=%s rpi=%s c1=%s rd=%s\n", - reason, - units_->capacitanceUnit()->asString(c2_), - units_->resistanceUnit()->asString(rpi_), - units_->capacitanceUnit()->asString(c1_), - units_->resistanceUnit()->asString(rd_)); + report_->reportLine("delay_calc: DMP failed - %s c2=%s rpi=%s c1=%s rd=%s", + reason, + units_->capacitanceUnit()->asString(c2_), + units_->resistanceUnit()->asString(rpi_), + units_->capacitanceUnit()->asString(c1_), + units_->resistanceUnit()->asString(rd_)); } //////////////////////////////////////////////////////////////// @@ -1001,7 +1000,7 @@ DmpPi::evalDmpEqns() showX(); showFvec(); showJacobian(); - debug_->print(".................\n"); + report_->reportLine("................."); } } @@ -1112,7 +1111,7 @@ DmpOnePole::evalDmpEqns() if (debug_->check("dmp_ceff", 4)) { showJacobian(); - debug_->print(".................\n"); + report_->reportLine("................."); } } diff --git a/dcalc/GraphDelayCalc1.cc b/dcalc/GraphDelayCalc1.cc index 08438471..ef95c4fe 100644 --- a/dcalc/GraphDelayCalc1.cc +++ b/dcalc/GraphDelayCalc1.cc @@ -402,7 +402,7 @@ void GraphDelayCalc1::findDelays(Level level) { if (arc_delay_calc_) { - Stats stats(debug_); + Stats stats(debug_, report_); int dcalc_count = 0; debugPrint1(debug_, "delay_calc", 1, "find delays to level %d", level); if (!delays_seeded_) { diff --git a/graph/Graph.cc b/graph/Graph.cc index 7b755dbc..abdb9f69 100644 --- a/graph/Graph.cc +++ b/graph/Graph.cc @@ -67,7 +67,7 @@ Graph::~Graph() void Graph::makeGraph() { - Stats stats(debug_); + Stats stats(debug_, report_); makeVerticesAndEdges(); makeWireEdges(); stats.report("Make graph"); diff --git a/include/sta/Debug.hh b/include/sta/Debug.hh index 3523179e..2521c01a 100644 --- a/include/sta/Debug.hh +++ b/include/sta/Debug.hh @@ -45,9 +45,6 @@ public: void setLevel(const char *what, int level); int statsLevel() const { return stats_level_; } - void print(const char *fmt, - ...) const - __attribute__((format (printf, 2, 3))); void reportLine(const char *what, const char *fmt, ...) const diff --git a/include/sta/Stats.hh b/include/sta/Stats.hh index 85379997..3b3693cc 100644 --- a/include/sta/Stats.hh +++ b/include/sta/Stats.hh @@ -22,12 +22,14 @@ namespace sta { class Debug; +class Report; // Show run time and memory statistics if the "stats" debug flag is on. class Stats { public: - explicit Stats(Debug *debug); + explicit Stats(Debug *debug, + Report *report); void report(const char *step); private: @@ -38,6 +40,7 @@ private: double system_begin_; size_t memory_begin_; Debug *debug_; + Report *report_; }; } // namespace diff --git a/sdc/SdcGraph.cc b/sdc/SdcGraph.cc index 5fca8d79..01f9d5b4 100644 --- a/sdc/SdcGraph.cc +++ b/sdc/SdcGraph.cc @@ -34,7 +34,7 @@ annotateGraphDisabledWireEdge(Pin *from_pin, void Sdc::annotateGraph() { - Stats stats(debug_); + Stats stats(debug_, report_); // All output pins are considered constrained because // they may be downstream from a set_min/max_delay -from that // does not have a set_output_delay. diff --git a/search/Genclks.cc b/search/Genclks.cc index ca7b1bf2..e6236af2 100644 --- a/search/Genclks.cc +++ b/search/Genclks.cc @@ -194,7 +194,7 @@ void Genclks::ensureInsertionDelays() { if (!found_insertion_delays_) { - Stats stats(debug_); + Stats stats(debug_, report_); debugPrint0(debug_, "genclk", 1, "find generated clk insertion delays"); ClockSeq gclks; diff --git a/search/Levelize.cc b/search/Levelize.cc index edeedc1a..00e37535 100644 --- a/search/Levelize.cc +++ b/search/Levelize.cc @@ -114,7 +114,7 @@ Levelize::ensureLevelized() void Levelize::levelize() { - Stats stats(debug_); + Stats stats(debug_, report_); debugPrint0(debug_, "levelize", 1, "levelize"); max_level_ = 0; clearLoopEdges(); diff --git a/search/PathEnum.cc b/search/PathEnum.cc index fe0fcabd..a6e1093c 100644 --- a/search/PathEnum.cc +++ b/search/PathEnum.cc @@ -176,10 +176,10 @@ PathEnum::findNext() Vertex *vertex = path_end->vertex(this); if (debug_->check("path_enum", 2)) { Path *path = path_end->path(); - debug_->print("path_enum: next path %s delay %s slack %s\n", - path->name(this), - delayAsString(path_end->dataArrivalTime(this), this), - delayAsString(path_end->slack(this), this)); + report_->reportLine("path_enum: next path %s delay %s slack %s", + path->name(this), + delayAsString(path_end->dataArrivalTime(this), this), + delayAsString(path_end->slack(this), this)); reportDiversionPath(div); } @@ -211,10 +211,10 @@ PathEnum::reportDiversionPath(Diversion *div) path->prevPath(this, p); Path *after_div = div->divPath(); while (!p.isNull()) { - debug_->print("path_enum: %s %s%s\n", - p.name(this), - delayAsString(p.arrival(this), this), - Path::equal(&p, after_div, this) ? " <-diversion" : ""); + report_->reportLine("path_enum: %s %s%s", + p.name(this), + delayAsString(p.arrival(this), this), + Path::equal(&p, after_div, this) ? " <-diversion" : ""); if (network_->isLatchData(p.pin(this))) break; p.prevPath(this, p); @@ -387,6 +387,7 @@ PathEnumFaninVisitor::reportDiversion(TimingArc *div_arc, { Debug *debug = sta_->debug(); if (debug->check("path_enum", 3)) { + Report *report = sta_->report(); Path *path = path_end_->path(); const PathAnalysisPt *path_ap = path->pathAnalysisPt(sta_); Arrival path_delay = path_enum_->cmp_slack_ @@ -397,16 +398,16 @@ PathEnumFaninVisitor::reportDiversion(TimingArc *div_arc, div_arc, path_ap); PathRef div_prev; before_div_.prevPath(sta_, div_prev); - debug->print("path_enum: diversion %s %s %s -> %s\n", - path->name(sta_), - path_enum_->cmp_slack_ ? "slack" : "delay", - delayAsString(path_delay, sta_), - delayAsString(div_delay, sta_)); - debug->print("path_enum: from %s -> %s\n", - div_prev.name(sta_), - before_div_.name(sta_)); - debug->print("path_enum: to %s ->\n", - after_div->name(sta_)); + report->reportLine("path_enum: diversion %s %s %s -> %s", + path->name(sta_), + path_enum_->cmp_slack_ ? "slack" : "delay", + delayAsString(path_delay, sta_), + delayAsString(div_delay, sta_)); + report->reportLine("path_enum: from %s -> %s", + div_prev.name(sta_), + before_div_.name(sta_)); + report->reportLine("path_enum: to %s ->e", + after_div->name(sta_)); } } diff --git a/search/PathGroup.cc b/search/PathGroup.cc index 4f6a8834..5da2c656 100644 --- a/search/PathGroup.cc +++ b/search/PathGroup.cc @@ -490,7 +490,7 @@ PathGroups::makePathEnds(ExceptionTo *to, const MinMaxAll *min_max, bool sort_by_slack) { - Stats stats(this->debug()); + Stats stats(debug_, report_); makeGroupPathEnds(to, group_count_, endpoint_count_, unique_pins_, corner, min_max); diff --git a/search/Search.cc b/search/Search.cc index 77829a28..d876e1bf 100644 --- a/search/Search.cc +++ b/search/Search.cc @@ -783,7 +783,7 @@ Search::findClkArrivals() { if (!clk_arrivals_valid_) { genclks_->ensureInsertionDelays(); - Stats stats(debug_); + Stats stats(debug_, report_); debugPrint0(debug_, "search", 1, "find clk arrivals"); arrival_iter_->clear(); seedClkVertexArrivals(); @@ -960,7 +960,7 @@ Search::findArrivals(Level level, { debugPrint1(debug_, "search", 1, "find arrivals to level %d", level); findArrivals1(); - Stats stats(debug_); + Stats stats(debug_, report_); int arrival_count = arrival_iter_->visitParallel(level, arrival_visitor); stats.report("Find arrivals"); if (arrival_iter_->empty() @@ -3070,7 +3070,7 @@ Search::findRequireds() void Search::findRequireds(Level level) { - Stats stats(debug_); + Stats stats(debug_, report_); debugPrint1(debug_, "search", 1, "find requireds to level %d", level); RequiredVisitor req_visitor(this); if (!requireds_seeded_) @@ -3118,7 +3118,8 @@ Search::endpoints() else { if (debug_->check("endpoint", 2) && endpoints_->hasKey(vertex)) - debug_->print("endpoint: remove %s\n", vertex->name(sdc_network_)); + report_->reportLine("endpoint: remove %s", + vertex->name(sdc_network_)); endpoints_->erase(vertex); } } diff --git a/search/Sim.cc b/search/Sim.cc index 47e78f51..3ccf1d3c 100644 --- a/search/Sim.cc +++ b/search/Sim.cc @@ -539,7 +539,7 @@ void Sim::ensureConstantsPropagated() { if (!valid_) { - Stats stats(debug_); + Stats stats(debug_, report_); ensureConstantFuncPins(); instances_to_annotate_.clear(); if (incremental_) { diff --git a/search/Sta.cc b/search/Sta.cc index 0a0ca382..3693882c 100644 --- a/search/Sta.cc +++ b/search/Sta.cc @@ -642,7 +642,7 @@ Sta::readLiberty(const char *filename, const MinMaxAll *min_max, bool infer_latches) { - Stats stats(debug_); + Stats stats(debug_, report_); LibertyLibrary *library = readLibertyFile(filename, corner, min_max, infer_latches, network_); if (library @@ -726,7 +726,7 @@ bool Sta::linkDesign(const char *top_cell_name) { clear(); - Stats stats(debug_); + Stats stats(debug_, report_); bool status = network_->linkNetwork(top_cell_name, link_make_black_boxes_, report_); diff --git a/util/Debug.cc b/util/Debug.cc index b5e6fa22..80b6740e 100644 --- a/util/Debug.cc +++ b/util/Debug.cc @@ -102,16 +102,6 @@ Debug::setLevel(const char *what, } } -void -Debug::print(const char *fmt, - ...) const -{ - va_list args; - va_start(args, fmt); - report_->vprint(fmt, args); - va_end(args); -} - void Debug::reportLine(const char *what, const char *fmt, diff --git a/util/Stats.cc b/util/Stats.cc index d27f89f0..f512308d 100644 --- a/util/Stats.cc +++ b/util/Stats.cc @@ -18,12 +18,15 @@ #include "Machine.hh" #include "StringUtil.hh" +#include "Report.hh" #include "Debug.hh" namespace sta { -Stats::Stats(Debug *debug) : - debug_(debug) +Stats::Stats(Debug *debug, + Report *report) : + debug_(debug), + report_(report) { if (debug->statsLevel() > 0) { elapsed_begin_ = elapsedRunTime(); @@ -42,11 +45,11 @@ Stats::report(const char *step) double memory_begin = static_cast(memory_begin_); double memory_end = static_cast(memoryUsage()); double memory_delta = memory_end - memory_begin; - debug_->print("stats: %5.1f/%5.1fe %5.1f/%5.1fu %5.1f/%5.1fMB %s\n", - elapsed_end - elapsed_begin_, elapsed_end, - user_end - user_begin_, user_end, - memory_delta * 1e-6, memory_end * 1e-6, - step); + report_->reportLine("stats: %5.1f/%5.1fe %5.1f/%5.1fu %5.1f/%5.1fMB %s", + elapsed_end - elapsed_begin_, elapsed_end, + user_end - user_begin_, user_end, + memory_delta * 1e-6, memory_end * 1e-6, + step); } } diff --git a/verilog/VerilogReader.cc b/verilog/VerilogReader.cc index 18ffe5a9..34a45cfb 100644 --- a/verilog/VerilogReader.cc +++ b/verilog/VerilogReader.cc @@ -183,7 +183,7 @@ VerilogReader::read(const char *filename) // Use zlib to uncompress gzip'd files automagically. stream_ = gzopen(filename, "rb"); if (stream_) { - Stats stats(debug_); + Stats stats(debug_, report_); init(filename); bool success = (::VerilogParse_parse() == 0); gzclose(stream_); @@ -682,20 +682,20 @@ VerilogReader::incrLine() } #define printClassMemory(name, class_name, count) \ - debug_->print(" %-20s %9d * %3d = %6.1fMb\n", \ - name, \ - count, \ - static_cast(sizeof(class_name)), \ - (count * sizeof(class_name) * 1e-6)) + report_->reportLine(" %-20s %9d * %3d = %6.1fMb\n", \ + name, \ + count, \ + static_cast(sizeof(class_name)), \ + (count * sizeof(class_name) * 1e-6)) #define printStringMemory(name, count) \ - debug_->print(" %-20s %6.1fMb\n", name, count * 1e-6) + report_->reportLine(" %-20s %6.1fMb", name, count * 1e-6) void VerilogReader::reportStmtCounts() { if (debugCheck(debug_, "verilog", 1)) { - debug_->print("Verilog stats\n"); + report_->reportLine("Verilog stats"); printClassMemory("modules", VerilogModule, module_count_); printClassMemory("module insts", VerilogModuleInst, inst_mod_count_); printClassMemory("liberty insts", VerilogLibertyInst, inst_lib_count_);