rm Debug::print

This commit is contained in:
James Cherry 2020-12-29 10:33:22 -08:00
parent 72aaf962c6
commit 9b1dc880f5
17 changed files with 99 additions and 103 deletions

View File

@ -486,16 +486,16 @@ ArnoldiReduce::makeRcmodelFromTs()
for (k=0;k<ts_ordN;k++) { for (k=0;k<ts_ordN;k++) {
p = ts_pordV[k]; p = ts_pordV[k];
debugPrint3(debug_, "arnoldi", 1, "T%d,P%ld c=%s", debugPrint3(debug_, "arnoldi", 1, "T%d,P%ld c=%s",
p->ts,p-p0, p->ts,
p-p0,
units_->capacitanceUnit()->asString(p->c)); units_->capacitanceUnit()->asString(p->c));
if (p->is_term) if (p->is_term)
debug_->print(" term%d", p->tindex); debugPrint1(debug_, "arnoldi", 1, " term %d", p->tindex);
if (p->in_edge) if (p->in_edge)
debug_->print(" from T%d,P%ld r=%s", debugPrint3(debug_, "arnoldi", 1, " from T%d,P%ld r=%s",
p->in_edge->from->ts, p->in_edge->from->ts,
p->in_edge->from-p0, p->in_edge->from-p0,
units_->resistanceUnit()->asString(p->r)); units_->resistanceUnit()->asString(p->r));
debug_->print("\n");
} }
for (i=0;i<nterms;i++) for (i=0;i<nterms;i++)
debugPrint2(debug_, "arnoldi", 1, "outV[%d] = T%d", i, outV[i]); debugPrint2(debug_, "arnoldi", 1, "outV[%d] = T%d", i, outV[i]);
@ -587,23 +587,25 @@ ArnoldiReduce::makeRcmodelFromTs()
} }
if (debug_->check("arnoldi", 1)) { if (debug_->check("arnoldi", 1)) {
debugPrint1(debug_, "arnoldi", 1, report_->reportLine("tridiagonal reduced matrix, drvr pin %s",
"tridiagonal reduced matrix, drvr pin %s", network_->pathName(drvr_pin_));
network_->pathName(drvr_pin_)); report_->reportLine("order %d n %d",order,n);
debugPrint2(debug_, "arnoldi", 1, "order %d n %d",order,n);
for (h=0;h<order;h++) { for (h=0;h<order;h++) {
debug_->print("d[%d] %s",
h,
units_->timeUnit()->asString(d[h]));
if (h<order-1) if (h<order-1)
debug_->print(" e[%d] %s", report_->reportLine(" d[%d] %s e[%d] %s",
h, h,
units_->timeUnit()->asString(e[h])); units_->timeUnit()->asString(d[h]),
debug_->print("\n"); h,
debug_->print("U[%d]",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;i<nterms;i++) for (i=0;i<nterms;i++)
debug_->print(" %6.2e",U[h][i]); line += stdstrPrint(" %6.2e",U[h][i]);
debug_->print("\n"); report_->reportLine(line);
} }
} }
} }

View File

@ -462,28 +462,29 @@ void
DmpAlg::showX() DmpAlg::showX()
{ {
for (int i = 0; i < nr_order_; i++) 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 void
DmpAlg::showFvec() DmpAlg::showFvec()
{ {
for (int i = 0; i < nr_order_; i++) 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 void
DmpAlg::showJacobian() DmpAlg::showJacobian()
{ {
debug_->print(" "); string line = " ";
for (int j = 0; j < nr_order_; j++) for (int j = 0; j < nr_order_; j++)
debug_->print("%12s", dmp_param_index_strings[j]); line += stdstrPrint("%12s", dmp_param_index_strings[j]);
debug_->print("\n"); report_->reportLine(line);
line.clear();
for (int i = 0; i < nr_order_; i++) { 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++) for (int j = 0; j < nr_order_; j++)
debug_->print("%12.3e ", fjac_[i][j]); line += stdstrPrint("%12.3e ", fjac_[i][j]);
debug_->print("\n"); report_->reportLine(line);
} }
} }
@ -545,12 +546,10 @@ DmpAlg::dVoDt(double t)
void void
DmpAlg::showVo() DmpAlg::showVo()
{ {
debug_->print(" t vo(t)\n"); report_->reportLine(" t vo(t)");
double ub = voCrossingUpperBound(); double ub = voCrossingUpperBound();
for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0) for (double t = t0_; t < t0_ + ub; t += dt_ / 10.0)
debug_->print(" %g %g\n", t, vo(t)); report_->reportLine(" %g %g", t, vo(t));
// debug_->print(" %.3g %.3g", t-t0_, vo(t)*3);
// debug_->print("\n");
} }
void void
@ -658,10 +657,10 @@ DmpAlg::dVlDt(double t)
void void
DmpAlg::showVl() DmpAlg::showVl()
{ {
debug_->print(" t vl(t)\n"); report_->reportLine(" t vl(t)");
double ub = vlCrossingUpperBound(); double ub = vlCrossingUpperBound();
for (double t = t0_; t < t0_ + ub * 2.0; t += ub / 10.0) 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 void
@ -669,12 +668,12 @@ DmpAlg::fail(const char *reason)
{ {
// Allow only failures to be reported with a unique debug flag. // Allow only failures to be reported with a unique debug flag.
if (debug_->check("dmp_ceff", 1) || debug_->check("dmp_ceff_fail", 1)) 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", report_->reportLine("delay_calc: DMP failed - %s c2=%s rpi=%s c1=%s rd=%s",
reason, reason,
units_->capacitanceUnit()->asString(c2_), units_->capacitanceUnit()->asString(c2_),
units_->resistanceUnit()->asString(rpi_), units_->resistanceUnit()->asString(rpi_),
units_->capacitanceUnit()->asString(c1_), units_->capacitanceUnit()->asString(c1_),
units_->resistanceUnit()->asString(rd_)); units_->resistanceUnit()->asString(rd_));
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -1001,7 +1000,7 @@ DmpPi::evalDmpEqns()
showX(); showX();
showFvec(); showFvec();
showJacobian(); showJacobian();
debug_->print(".................\n"); report_->reportLine(".................");
} }
} }
@ -1112,7 +1111,7 @@ DmpOnePole::evalDmpEqns()
if (debug_->check("dmp_ceff", 4)) { if (debug_->check("dmp_ceff", 4)) {
showJacobian(); showJacobian();
debug_->print(".................\n"); report_->reportLine(".................");
} }
} }

View File

@ -402,7 +402,7 @@ void
GraphDelayCalc1::findDelays(Level level) GraphDelayCalc1::findDelays(Level level)
{ {
if (arc_delay_calc_) { if (arc_delay_calc_) {
Stats stats(debug_); Stats stats(debug_, report_);
int dcalc_count = 0; int dcalc_count = 0;
debugPrint1(debug_, "delay_calc", 1, "find delays to level %d", level); debugPrint1(debug_, "delay_calc", 1, "find delays to level %d", level);
if (!delays_seeded_) { if (!delays_seeded_) {

View File

@ -67,7 +67,7 @@ Graph::~Graph()
void void
Graph::makeGraph() Graph::makeGraph()
{ {
Stats stats(debug_); Stats stats(debug_, report_);
makeVerticesAndEdges(); makeVerticesAndEdges();
makeWireEdges(); makeWireEdges();
stats.report("Make graph"); stats.report("Make graph");

View File

@ -45,9 +45,6 @@ public:
void setLevel(const char *what, void setLevel(const char *what,
int level); int level);
int statsLevel() const { return stats_level_; } int statsLevel() const { return stats_level_; }
void print(const char *fmt,
...) const
__attribute__((format (printf, 2, 3)));
void reportLine(const char *what, void reportLine(const char *what,
const char *fmt, const char *fmt,
...) const ...) const

View File

@ -22,12 +22,14 @@
namespace sta { namespace sta {
class Debug; class Debug;
class Report;
// Show run time and memory statistics if the "stats" debug flag is on. // Show run time and memory statistics if the "stats" debug flag is on.
class Stats class Stats
{ {
public: public:
explicit Stats(Debug *debug); explicit Stats(Debug *debug,
Report *report);
void report(const char *step); void report(const char *step);
private: private:
@ -38,6 +40,7 @@ private:
double system_begin_; double system_begin_;
size_t memory_begin_; size_t memory_begin_;
Debug *debug_; Debug *debug_;
Report *report_;
}; };
} // namespace } // namespace

View File

@ -34,7 +34,7 @@ annotateGraphDisabledWireEdge(Pin *from_pin,
void void
Sdc::annotateGraph() Sdc::annotateGraph()
{ {
Stats stats(debug_); Stats stats(debug_, report_);
// All output pins are considered constrained because // All output pins are considered constrained because
// they may be downstream from a set_min/max_delay -from that // they may be downstream from a set_min/max_delay -from that
// does not have a set_output_delay. // does not have a set_output_delay.

View File

@ -194,7 +194,7 @@ void
Genclks::ensureInsertionDelays() Genclks::ensureInsertionDelays()
{ {
if (!found_insertion_delays_) { if (!found_insertion_delays_) {
Stats stats(debug_); Stats stats(debug_, report_);
debugPrint0(debug_, "genclk", 1, "find generated clk insertion delays"); debugPrint0(debug_, "genclk", 1, "find generated clk insertion delays");
ClockSeq gclks; ClockSeq gclks;

View File

@ -114,7 +114,7 @@ Levelize::ensureLevelized()
void void
Levelize::levelize() Levelize::levelize()
{ {
Stats stats(debug_); Stats stats(debug_, report_);
debugPrint0(debug_, "levelize", 1, "levelize"); debugPrint0(debug_, "levelize", 1, "levelize");
max_level_ = 0; max_level_ = 0;
clearLoopEdges(); clearLoopEdges();

View File

@ -176,10 +176,10 @@ PathEnum::findNext()
Vertex *vertex = path_end->vertex(this); Vertex *vertex = path_end->vertex(this);
if (debug_->check("path_enum", 2)) { if (debug_->check("path_enum", 2)) {
Path *path = path_end->path(); Path *path = path_end->path();
debug_->print("path_enum: next path %s delay %s slack %s\n", report_->reportLine("path_enum: next path %s delay %s slack %s",
path->name(this), path->name(this),
delayAsString(path_end->dataArrivalTime(this), this), delayAsString(path_end->dataArrivalTime(this), this),
delayAsString(path_end->slack(this), this)); delayAsString(path_end->slack(this), this));
reportDiversionPath(div); reportDiversionPath(div);
} }
@ -211,10 +211,10 @@ PathEnum::reportDiversionPath(Diversion *div)
path->prevPath(this, p); path->prevPath(this, p);
Path *after_div = div->divPath(); Path *after_div = div->divPath();
while (!p.isNull()) { while (!p.isNull()) {
debug_->print("path_enum: %s %s%s\n", report_->reportLine("path_enum: %s %s%s",
p.name(this), p.name(this),
delayAsString(p.arrival(this), this), delayAsString(p.arrival(this), this),
Path::equal(&p, after_div, this) ? " <-diversion" : ""); Path::equal(&p, after_div, this) ? " <-diversion" : "");
if (network_->isLatchData(p.pin(this))) if (network_->isLatchData(p.pin(this)))
break; break;
p.prevPath(this, p); p.prevPath(this, p);
@ -387,6 +387,7 @@ PathEnumFaninVisitor::reportDiversion(TimingArc *div_arc,
{ {
Debug *debug = sta_->debug(); Debug *debug = sta_->debug();
if (debug->check("path_enum", 3)) { if (debug->check("path_enum", 3)) {
Report *report = sta_->report();
Path *path = path_end_->path(); Path *path = path_end_->path();
const PathAnalysisPt *path_ap = path->pathAnalysisPt(sta_); const PathAnalysisPt *path_ap = path->pathAnalysisPt(sta_);
Arrival path_delay = path_enum_->cmp_slack_ Arrival path_delay = path_enum_->cmp_slack_
@ -397,16 +398,16 @@ PathEnumFaninVisitor::reportDiversion(TimingArc *div_arc,
div_arc, path_ap); div_arc, path_ap);
PathRef div_prev; PathRef div_prev;
before_div_.prevPath(sta_, div_prev); before_div_.prevPath(sta_, div_prev);
debug->print("path_enum: diversion %s %s %s -> %s\n", report->reportLine("path_enum: diversion %s %s %s -> %s",
path->name(sta_), path->name(sta_),
path_enum_->cmp_slack_ ? "slack" : "delay", path_enum_->cmp_slack_ ? "slack" : "delay",
delayAsString(path_delay, sta_), delayAsString(path_delay, sta_),
delayAsString(div_delay, sta_)); delayAsString(div_delay, sta_));
debug->print("path_enum: from %s -> %s\n", report->reportLine("path_enum: from %s -> %s",
div_prev.name(sta_), div_prev.name(sta_),
before_div_.name(sta_)); before_div_.name(sta_));
debug->print("path_enum: to %s ->\n", report->reportLine("path_enum: to %s ->e",
after_div->name(sta_)); after_div->name(sta_));
} }
} }

View File

@ -490,7 +490,7 @@ PathGroups::makePathEnds(ExceptionTo *to,
const MinMaxAll *min_max, const MinMaxAll *min_max,
bool sort_by_slack) bool sort_by_slack)
{ {
Stats stats(this->debug()); Stats stats(debug_, report_);
makeGroupPathEnds(to, group_count_, endpoint_count_, unique_pins_, makeGroupPathEnds(to, group_count_, endpoint_count_, unique_pins_,
corner, min_max); corner, min_max);

View File

@ -783,7 +783,7 @@ Search::findClkArrivals()
{ {
if (!clk_arrivals_valid_) { if (!clk_arrivals_valid_) {
genclks_->ensureInsertionDelays(); genclks_->ensureInsertionDelays();
Stats stats(debug_); Stats stats(debug_, report_);
debugPrint0(debug_, "search", 1, "find clk arrivals"); debugPrint0(debug_, "search", 1, "find clk arrivals");
arrival_iter_->clear(); arrival_iter_->clear();
seedClkVertexArrivals(); seedClkVertexArrivals();
@ -960,7 +960,7 @@ Search::findArrivals(Level level,
{ {
debugPrint1(debug_, "search", 1, "find arrivals to level %d", level); debugPrint1(debug_, "search", 1, "find arrivals to level %d", level);
findArrivals1(); findArrivals1();
Stats stats(debug_); Stats stats(debug_, report_);
int arrival_count = arrival_iter_->visitParallel(level, arrival_visitor); int arrival_count = arrival_iter_->visitParallel(level, arrival_visitor);
stats.report("Find arrivals"); stats.report("Find arrivals");
if (arrival_iter_->empty() if (arrival_iter_->empty()
@ -3070,7 +3070,7 @@ Search::findRequireds()
void void
Search::findRequireds(Level level) Search::findRequireds(Level level)
{ {
Stats stats(debug_); Stats stats(debug_, report_);
debugPrint1(debug_, "search", 1, "find requireds to level %d", level); debugPrint1(debug_, "search", 1, "find requireds to level %d", level);
RequiredVisitor req_visitor(this); RequiredVisitor req_visitor(this);
if (!requireds_seeded_) if (!requireds_seeded_)
@ -3118,7 +3118,8 @@ Search::endpoints()
else { else {
if (debug_->check("endpoint", 2) if (debug_->check("endpoint", 2)
&& endpoints_->hasKey(vertex)) && 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); endpoints_->erase(vertex);
} }
} }

View File

@ -539,7 +539,7 @@ void
Sim::ensureConstantsPropagated() Sim::ensureConstantsPropagated()
{ {
if (!valid_) { if (!valid_) {
Stats stats(debug_); Stats stats(debug_, report_);
ensureConstantFuncPins(); ensureConstantFuncPins();
instances_to_annotate_.clear(); instances_to_annotate_.clear();
if (incremental_) { if (incremental_) {

View File

@ -642,7 +642,7 @@ Sta::readLiberty(const char *filename,
const MinMaxAll *min_max, const MinMaxAll *min_max,
bool infer_latches) bool infer_latches)
{ {
Stats stats(debug_); Stats stats(debug_, report_);
LibertyLibrary *library = readLibertyFile(filename, corner, min_max, LibertyLibrary *library = readLibertyFile(filename, corner, min_max,
infer_latches, network_); infer_latches, network_);
if (library if (library
@ -726,7 +726,7 @@ bool
Sta::linkDesign(const char *top_cell_name) Sta::linkDesign(const char *top_cell_name)
{ {
clear(); clear();
Stats stats(debug_); Stats stats(debug_, report_);
bool status = network_->linkNetwork(top_cell_name, bool status = network_->linkNetwork(top_cell_name,
link_make_black_boxes_, link_make_black_boxes_,
report_); report_);

View File

@ -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 void
Debug::reportLine(const char *what, Debug::reportLine(const char *what,
const char *fmt, const char *fmt,

View File

@ -18,12 +18,15 @@
#include "Machine.hh" #include "Machine.hh"
#include "StringUtil.hh" #include "StringUtil.hh"
#include "Report.hh"
#include "Debug.hh" #include "Debug.hh"
namespace sta { namespace sta {
Stats::Stats(Debug *debug) : Stats::Stats(Debug *debug,
debug_(debug) Report *report) :
debug_(debug),
report_(report)
{ {
if (debug->statsLevel() > 0) { if (debug->statsLevel() > 0) {
elapsed_begin_ = elapsedRunTime(); elapsed_begin_ = elapsedRunTime();
@ -42,11 +45,11 @@ Stats::report(const char *step)
double memory_begin = static_cast<double>(memory_begin_); double memory_begin = static_cast<double>(memory_begin_);
double memory_end = static_cast<double>(memoryUsage()); double memory_end = static_cast<double>(memoryUsage());
double memory_delta = memory_end - memory_begin; double memory_delta = memory_end - memory_begin;
debug_->print("stats: %5.1f/%5.1fe %5.1f/%5.1fu %5.1f/%5.1fMB %s\n", report_->reportLine("stats: %5.1f/%5.1fe %5.1f/%5.1fu %5.1f/%5.1fMB %s",
elapsed_end - elapsed_begin_, elapsed_end, elapsed_end - elapsed_begin_, elapsed_end,
user_end - user_begin_, user_end, user_end - user_begin_, user_end,
memory_delta * 1e-6, memory_end * 1e-6, memory_delta * 1e-6, memory_end * 1e-6,
step); step);
} }
} }

View File

@ -183,7 +183,7 @@ VerilogReader::read(const char *filename)
// Use zlib to uncompress gzip'd files automagically. // Use zlib to uncompress gzip'd files automagically.
stream_ = gzopen(filename, "rb"); stream_ = gzopen(filename, "rb");
if (stream_) { if (stream_) {
Stats stats(debug_); Stats stats(debug_, report_);
init(filename); init(filename);
bool success = (::VerilogParse_parse() == 0); bool success = (::VerilogParse_parse() == 0);
gzclose(stream_); gzclose(stream_);
@ -682,20 +682,20 @@ VerilogReader::incrLine()
} }
#define printClassMemory(name, class_name, count) \ #define printClassMemory(name, class_name, count) \
debug_->print(" %-20s %9d * %3d = %6.1fMb\n", \ report_->reportLine(" %-20s %9d * %3d = %6.1fMb\n", \
name, \ name, \
count, \ count, \
static_cast<int>(sizeof(class_name)), \ static_cast<int>(sizeof(class_name)), \
(count * sizeof(class_name) * 1e-6)) (count * sizeof(class_name) * 1e-6))
#define printStringMemory(name, count) \ #define printStringMemory(name, count) \
debug_->print(" %-20s %6.1fMb\n", name, count * 1e-6) report_->reportLine(" %-20s %6.1fMb", name, count * 1e-6)
void void
VerilogReader::reportStmtCounts() VerilogReader::reportStmtCounts()
{ {
if (debugCheck(debug_, "verilog", 1)) { if (debugCheck(debug_, "verilog", 1)) {
debug_->print("Verilog stats\n"); report_->reportLine("Verilog stats");
printClassMemory("modules", VerilogModule, module_count_); printClassMemory("modules", VerilogModule, module_count_);
printClassMemory("module insts", VerilogModuleInst, inst_mod_count_); printClassMemory("module insts", VerilogModuleInst, inst_mod_count_);
printClassMemory("liberty insts", VerilogLibertyInst, inst_lib_count_); printClassMemory("liberty insts", VerilogLibertyInst, inst_lib_count_);