Skip to content

Commit 86dc1f4

Browse files
committed
gpl: modify debuging nbc_gcells_ to file
Signed-off-by: Augusto Berndt <augusto.berndt@precisioninno.com>
1 parent 9bc390e commit 86dc1f4

2 files changed

Lines changed: 35 additions & 14 deletions

File tree

src/gpl/src/nesterovBase.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,9 @@ void GCell::print(utl::Logger* logger, bool print_only_name = true) const
282282
}
283283
}
284284

285-
void GCell::printToFile(const std::string& filename,
286-
bool print_only_name = true) const
285+
void GCell::printToFile(std::ostream& out, bool print_only_name) const
287286
{
288-
std::ofstream out(filename, std::ios::app);
289-
if (!out.is_open()) {
287+
if (!out) {
290288
return;
291289
}
292290

@@ -307,8 +305,6 @@ void GCell::printToFile(const std::string& filename,
307305
gradientX_,
308306
gradientY_);
309307
}
310-
311-
out.close();
312308
}
313309

314310
////////////////////////////////////////////////
@@ -3367,21 +3363,44 @@ void NesterovBaseCommon::printGCells()
33673363
}
33683364
}
33693365

3370-
void NesterovBaseCommon::printGCellsToFile(const std::string& filename)
3366+
void NesterovBaseCommon::printGCellsToFile(const std::string& filename,
3367+
bool print_only_name,
3368+
bool also_print_minRc)
33713369
{
33723370
std::ofstream out(filename);
33733371
if (!out.is_open()) {
33743372
return;
33753373
}
33763374

33773375
out << "gCellStor_.size(): " << gCellStor_.size() << "\n";
3378-
out.close(); // reuse printToFile which appends
3376+
out.close();
3377+
3378+
std::ofstream out_append(filename, std::ios::app);
3379+
if (!out_append.is_open()) {
3380+
return;
3381+
}
33793382

33803383
for (size_t i = 0; i < gCellStor_.size(); ++i) {
3381-
std::ofstream out_idx(filename, std::ios::app);
3382-
out_idx << fmt::format("idx:{}\n", i);
3383-
out_idx.close();
3384-
gCellStor_[i].printToFile(filename);
3384+
out_append << fmt::format("idx:{}\n", i);
3385+
gCellStor_[i].printToFile(out_append, print_only_name);
3386+
}
3387+
3388+
out_append.close();
3389+
3390+
if (also_print_minRc) {
3391+
std::string minrc_filename = filename + ".minrc";
3392+
std::ofstream minrc_out(minrc_filename);
3393+
if (!minrc_out.is_open()) {
3394+
return;
3395+
}
3396+
3397+
for (size_t i = 0; i < minRcCellSize_.size(); ++i) {
3398+
const auto& min_rc = minRcCellSize_[i];
3399+
minrc_out << fmt::format(
3400+
"idx:{} minRc: {} {}\n", i, min_rc.first, min_rc.second);
3401+
}
3402+
3403+
minrc_out.close();
33853404
}
33863405
}
33873406

src/gpl/src/nesterovBase.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class GCell
111111
bool contains(odb::dbInst* db_inst) const;
112112

113113
void print(utl::Logger* logger, bool print_only_name) const;
114-
void printToFile(const std::string& filename, bool print_only_name) const;
114+
void printToFile(std::ostream& out, bool print_only_name = true) const;
115115

116116
private:
117117
std::vector<Instance*> insts_;
@@ -851,7 +851,9 @@ class NesterovBaseCommon
851851
}
852852

853853
void printGCells();
854-
void printGCellsToFile(const std::string& filename);
854+
void printGCellsToFile(const std::string& filename,
855+
bool print_only_name = true,
856+
bool also_print_minRc = false);
855857
void printGPins();
856858

857859
// TODO do this for each region? Also, manage this properly if other callbacks

0 commit comments

Comments
 (0)