Skip to content

Commit

Permalink
Merge pull request #6280 from gadfort/dpl-verbose-filler
Browse files Browse the repository at this point in the history
dpl: add verbose flag to filler_placement to print filler cell usage
  • Loading branch information
maliberty authored Dec 2, 2024
2 parents 3683272 + f37c78a commit f6a30a6
Show file tree
Hide file tree
Showing 14 changed files with 121 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/dpl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ from `FILLER_` use `-prefix <new prefix>`.
```tcl
filler_placement
[-prefix prefix]
[-verbose]
filler_masters
```

Expand All @@ -87,6 +88,7 @@ filler_placement
| Switch Name | Description |
| ----- | ----- |
| `-prefix` | Prefix to name the filler cells. The default value is `FILLER_`. |
| `-verbose` | Print the filler cell usage. |
| `filler_masters` | Filler master cells. |

### Remove Fillers
Expand Down
6 changes: 4 additions & 2 deletions src/dpl/include/dpl/Opendp.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ class Opendp
void checkPlacement(bool verbose,
bool disallow_one_site_gaps = false,
const string& report_file_name = "");
void fillerPlacement(dbMasterSeq* filler_masters, const char* prefix);
void fillerPlacement(dbMasterSeq* filler_masters,
const char* prefix,
bool verbose);
void removeFillers();
void optimizeMirroring();

Expand Down Expand Up @@ -363,7 +365,7 @@ class Opendp
// Filler placement.
// gap (in sites) -> seq of masters by implant
map<dbTechLayer*, GapFillers> gap_fillers_;
int filler_count_ = 0;
map<dbMaster*, int> filler_count_;
bool have_fillers_ = false;
bool have_one_site_cells_ = false;

Expand Down
31 changes: 27 additions & 4 deletions src/dpl/src/FillerPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ Opendp::MasterByImplant Opendp::splitByImplant(dbMasterSeq* filler_masters)
return mapping;
}

void Opendp::fillerPlacement(dbMasterSeq* filler_masters, const char* prefix)
void Opendp::fillerPlacement(dbMasterSeq* filler_masters,
const char* prefix,
bool verbose)
{
if (cells_.empty()) {
importDb();
Expand All @@ -92,15 +94,36 @@ void Opendp::fillerPlacement(dbMasterSeq* filler_masters, const char* prefix)
}

gap_fillers_.clear();
filler_count_ = 0;
filler_count_.clear();
initGrid();
setGridCells();

for (GridY row{0}; row < grid_->getRowCount(); row++) {
placeRowFillers(row, prefix, filler_masters_by_implant);
}

logger_->info(DPL, 1, "Placed {} filler instances.", filler_count_);
int filler_count = 0;
int max_filler_master = 0;
for (const auto& [master, count] : filler_count_) {
filler_count += count;
max_filler_master = std::max(max_filler_master, count);
}
logger_->info(DPL, 1, "Placed {} filler instances.", filler_count);

if (verbose) {
logger_->report("Filler usage:");
int max_master_len = 0;
for (const auto& [master, count] : filler_count_) {
max_master_len = std::max(max_master_len,
static_cast<int>(master->getName().size()));
}
const int count_offset = fmt::format("{}", max_filler_master).size();
for (const auto& [master, count] : filler_count_) {
const int line_offset
= count_offset + max_master_len - master->getName().size();
logger_->report(" {}: {:>{}}", master->getName(), count, line_offset);
}
}
}

void Opendp::setGridCells()
Expand Down Expand Up @@ -197,7 +220,7 @@ void Opendp::placeRowFillers(GridY row,
inst->setLocation(x.v, y.v);
inst->setPlacementStatus(dbPlacementStatus::PLACED);
inst->setSourceType(odb::dbSourceType::DIST);
filler_count_++;
filler_count_[master]++;
k += master->getWidth() / site_width.v;
}
j += gap;
Expand Down
5 changes: 3 additions & 2 deletions src/dpl/src/Opendp.i
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ set_padding_inst(odb::dbInst *inst,

void
filler_placement_cmd(dpl::dbMasterSeq *filler_masters,
const char* prefix)
const char* prefix,
bool verbose)
{
dpl::Opendp *opendp = ord::OpenRoad::openRoad()->getOpendp();
opendp->fillerPlacement(filler_masters, prefix);
opendp->fillerPlacement(filler_masters, prefix, verbose);
}

void
Expand Down
6 changes: 3 additions & 3 deletions src/dpl/src/Opendp.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ proc set_placement_padding { args } {
}
}

sta::define_cmd_args "filler_placement" { [-prefix prefix] filler_masters }
sta::define_cmd_args "filler_placement" { [-prefix prefix] [-verbose] filler_masters }

proc filler_placement { args } {
sta::parse_key_args "filler_placement" args \
keys {-prefix} flags {}
keys {-prefix} flags {-verbose}

set prefix "FILLER_"
if { [info exists keys(-prefix)] } {
Expand All @@ -133,7 +133,7 @@ proc filler_placement { args } {

sta::check_argc_eq1 "filler_placement" $args
set filler_masters [dpl::get_masters_arg "filler_masters" [lindex $args 0]]
dpl::filler_placement_cmd $filler_masters $prefix
dpl::filler_placement_cmd $filler_masters $prefix [info exists flags(-verbose)]
}

sta::define_cmd_args "remove_fillers" {}
Expand Down
2 changes: 2 additions & 0 deletions src/dpl/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ set(TEST_NAMES
fillers7
fillers8
fillers9
fillers2_verbose
fillers9_verbose
fragmented_row01
fragmented_row02
fragmented_row03
Expand Down
4 changes: 2 additions & 2 deletions src/dpl/test/dpl_aux.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def set_placement_padding(design, *, masters=None, right=None, left=None, globl=
utl.warn(utl.DPL, 103, "No padding target specified")


def filler_placement(design, prefix=None, masters=None):
def filler_placement(design, prefix=None, masters=None, verbose=False):
dpl = design.getOpendp()
if prefix == None:
prefix = "FILLER_"
Expand All @@ -73,7 +73,7 @@ def filler_placement(design, prefix=None, masters=None):

filler_masters = get_masters(design, masters)
if len(filler_masters) > 0:
dpl.fillerPlacement(filler_masters, prefix)
dpl.fillerPlacement(filler_masters, prefix, verbose)


def get_masters(design, names):
Expand Down
22 changes: 22 additions & 0 deletions src/dpl/test/fillers2_verbose.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
[INFO ODB-0128] Design: single_cell
[INFO ODB-0130] Created 2 pins.
[INFO ODB-0131] Created 1 components and 4 component-terminals.
[INFO ODB-0132] Created 2 special nets and 2 connections.
[INFO ODB-0133] Created 2 nets and 2 connections.
Placement Analysis
---------------------------------
total displacement 3.7 u
average displacement 3.7 u
max displacement 3.7 u
original HPWL 2.3 u
legalized HPWL 9.9 u
delta HPWL 332 %

[INFO DPL-0001] Placed 8 filler instances.
Filler usage:
FILLCELL_X1: 1
FILLCELL_X16: 1
FILLCELL_X2: 2
FILLCELL_X32: 3
FILLCELL_X4: 1
13 changes: 13 additions & 0 deletions src/dpl/test/fillers2_verbose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# filler_placement with set_placement_padding
from openroad import Design, Tech
import helpers
import dpl_aux

tech = Tech()
tech.readLef("Nangate45/Nangate45.lef")
design = helpers.make_design(tech)
design.readDef("simple01.def")
dpl_aux.set_placement_padding(design, globl=True, left=2, right=2)

dpl_aux.detailed_placement(design)
dpl_aux.filler_placement(design, masters=["FILL.*"], verbose=True)
8 changes: 8 additions & 0 deletions src/dpl/test/fillers2_verbose.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# filler_placement with set_placement_padding with verbose
source "helpers.tcl"
read_lef Nangate45/Nangate45.lef
read_def simple01.def
set_placement_padding -global -left 2 -right 2

detailed_placement
filler_placement FILL* -verbose
16 changes: 16 additions & 0 deletions src/dpl/test/fillers9_verbose.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[INFO ODB-0227] LEF file: fillers9.lef, created 5 layers, 14 library cells
[INFO ODB-0128] Design: fillers9
[INFO ODB-0131] Created 8 components and 32 component-terminals.
[INFO DPL-0001] Placed 22 filler instances.
Filler usage:
FILLCELL_RVT_X1: 1
FILLCELL_RVT_X16: 2
FILLCELL_RVT_X2: 3
FILLCELL_RVT_X32: 1
FILLCELL_RVT_X4: 2
FILLCELL_RVT_X8: 2
FILLCELL_LVT_X1: 1
FILLCELL_LVT_X16: 3
FILLCELL_LVT_X2: 2
FILLCELL_LVT_X4: 3
FILLCELL_LVT_X8: 2
11 changes: 11 additions & 0 deletions src/dpl/test/fillers9_verbose.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# filler_placement with verbose
from openroad import Tech
import helpers
import dpl_aux

tech = Tech()
tech.readLef("fillers9.lef")
design = helpers.make_design(tech)
design.readDef("fillers9.def")

dpl_aux.filler_placement(design, masters=["FILL.*"], verbose=True)
6 changes: 6 additions & 0 deletions src/dpl/test/fillers9_verbose.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# filler_placement with verbose
source "helpers.tcl"
read_lef fillers9.lef
read_def fillers9.def

filler_placement FILL* -verbose
2 changes: 2 additions & 0 deletions src/dpl/test/regression_tests.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ record_tests {
fillers7
fillers8
fillers9
fillers2_verbose
fillers9_verbose
fragmented_row01
fragmented_row02
fragmented_row03
Expand Down

0 comments on commit f6a30a6

Please sign in to comment.