Skip to content

Commit d872e77

Browse files
authored
Merge pull request #8934 from gudeh/gpl-area-weight-by-pin
gpl: modify instance area based on averaga instances pin density
2 parents 465c716 + 0ce987c commit d872e77

File tree

110 files changed

+1253188
-1252888
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1253188
-1252888
lines changed

src/cts/test/gated_clock4.ok

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ Using 2 tracks default min distance between IO pins.
2727
[INFO GPL-0014] Region name: top-level.
2828
[INFO GPL-0015] Region area: 999570.012 um^2
2929
[INFO GPL-0017] Fixed instances area: 0.000 um^2
30-
[INFO GPL-0018] Movable instances area: 1274.406 um^2
30+
[INFO GPL-0018] Movable instances area: 1274.067 um^2
3131
[INFO GPL-0019] Utilization: 0.127 %
32-
[INFO GPL-0020] Standard cells area: 1274.406 um^2
32+
[INFO GPL-0020] Standard cells area: 1274.067 um^2
3333
[INFO GPL-0021] Large instances area: 0.000 um^2
3434
[InitialPlace] Iter: 1 conjugate gradient residual: 0.00000010 HPWL: 3046720
35-
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000009 HPWL: 74872
36-
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000008 HPWL: 61495
37-
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000011 HPWL: 61497
38-
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000011 HPWL: 61495
35+
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000009 HPWL: 74682
36+
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000008 HPWL: 61445
37+
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000011 HPWL: 61447
38+
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000011 HPWL: 61445
3939
Placement Analysis
4040
---------------------------------
41-
total displacement 6730.6 u
41+
total displacement 6730.7 u
4242
average displacement 23.8 u
4343
max displacement 35.5 u
44-
original HPWL 0.8 u
44+
original HPWL 0.9 u
4545
legalized HPWL 388.7 u
46-
delta HPWL 49070 %
46+
delta HPWL 44019 %
4747

4848
[INFO CTS-0050] Root buffer is CLKBUF_X3.
4949
[INFO CTS-0051] Sink buffer is CLKBUF_X3.

src/cts/test/hier_insertion_delay.ok

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ Using 2 tracks default min distance between IO pins.
2929
[INFO GPL-0014] Region name: top-level.
3030
[INFO GPL-0015] Region area: 47872.020 um^2
3131
[INFO GPL-0017] Fixed instances area: 0.000 um^2
32-
[INFO GPL-0018] Movable instances area: 1357.116 um^2
33-
[INFO GPL-0019] Utilization: 2.835 %
34-
[INFO GPL-0020] Standard cells area: 1257.116 um^2
35-
[INFO GPL-0021] Large instances area: 100.000 um^2
32+
[INFO GPL-0018] Movable instances area: 1440.760 um^2
33+
[INFO GPL-0019] Utilization: 3.010 %
34+
[INFO GPL-0020] Standard cells area: 1350.510 um^2
35+
[INFO GPL-0021] Large instances area: 90.250 um^2
3636
[InitialPlace] Iter: 1 conjugate gradient residual: 0.00000012 HPWL: 1220290
37-
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000012 HPWL: 1230290
38-
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000012 HPWL: 1230290
39-
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000012 HPWL: 1230290
40-
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000012 HPWL: 1230290
37+
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000012 HPWL: 1229790
38+
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000012 HPWL: 1229790
39+
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000012 HPWL: 1229790
40+
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000012 HPWL: 1229790
4141
Placement Analysis
4242
---------------------------------
43-
total displacement 9363.8 u
43+
total displacement 9387.3 u
4444
average displacement 33.6 u
45-
max displacement 51.7 u
46-
original HPWL 605.2 u
47-
legalized HPWL 641.6 u
45+
max displacement 51.8 u
46+
original HPWL 605.0 u
47+
legalized HPWL 641.4 u
4848
delta HPWL 6 %
4949

5050
[INFO CTS-0050] Root buffer is CLKBUF_X3.
@@ -64,8 +64,8 @@ delta HPWL 6 %
6464
[INFO CTS-0030] Number of static layers: 1.
6565
[INFO CTS-0020] Wire segment unit: 14000 dbu (7 um).
6666
[INFO CTS-0021] Distance between buffers: 7 units (100 um).
67-
[INFO CTS-0023] Original sink region: [(-10000, 9999), (-10000, 9999)].
68-
[INFO CTS-0024] Normalized sink region: [(-0.714286, 0.714214), (-0.714286, 0.714214)].
67+
[INFO CTS-0023] Original sink region: [(-9500, 10499), (-9500, 10499)].
68+
[INFO CTS-0024] Normalized sink region: [(-0.678571, 0.749929), (-0.678571, 0.749929)].
6969
[INFO CTS-0025] Width: 0.0000.
7070
[INFO CTS-0026] Height: 0.0000.
7171
Level 1

src/dbSta/test/escape_slash.ok

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,23 @@ Using 2 tracks default min distance between IO pins.
2626
[INFO GPL-0014] Region name: top-level.
2727
[INFO GPL-0015] Region area: 999570.012 um^2
2828
[INFO GPL-0017] Fixed instances area: 0.000 um^2
29-
[INFO GPL-0018] Movable instances area: 1274.406 um^2
29+
[INFO GPL-0018] Movable instances area: 1274.067 um^2
3030
[INFO GPL-0019] Utilization: 0.127 %
31-
[INFO GPL-0020] Standard cells area: 1274.406 um^2
31+
[INFO GPL-0020] Standard cells area: 1274.067 um^2
3232
[INFO GPL-0021] Large instances area: 0.000 um^2
3333
[InitialPlace] Iter: 1 conjugate gradient residual: 0.00186203 HPWL: 3046720
34-
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000010 HPWL: 125934
35-
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000010 HPWL: 61497
36-
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000008 HPWL: 61494
37-
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000009 HPWL: 61497
34+
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000010 HPWL: 125772
35+
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000010 HPWL: 61447
36+
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000008 HPWL: 61444
37+
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000009 HPWL: 61447
3838
Placement Analysis
3939
---------------------------------
40-
total displacement 6730.7 u
40+
total displacement 6730.8 u
4141
average displacement 23.8 u
4242
max displacement 35.5 u
43-
original HPWL 0.8 u
43+
original HPWL 0.9 u
4444
legalized HPWL 454.9 u
45-
delta HPWL 56871 %
45+
delta HPWL 51331 %
4646

4747
[INFO CTS-0050] Root buffer is CLKBUF_X3.
4848
[INFO CTS-0051] Sink buffer is CLKBUF_X3.

src/dbSta/test/escape_slash_hier.ok

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ Using 2 tracks default min distance between IO pins.
2727
[INFO GPL-0014] Region name: top-level.
2828
[INFO GPL-0015] Region area: 999570.012 um^2
2929
[INFO GPL-0017] Fixed instances area: 0.000 um^2
30-
[INFO GPL-0018] Movable instances area: 1274.406 um^2
30+
[INFO GPL-0018] Movable instances area: 1274.067 um^2
3131
[INFO GPL-0019] Utilization: 0.127 %
32-
[INFO GPL-0020] Standard cells area: 1274.406 um^2
32+
[INFO GPL-0020] Standard cells area: 1274.067 um^2
3333
[INFO GPL-0021] Large instances area: 0.000 um^2
3434
[InitialPlace] Iter: 1 conjugate gradient residual: 0.00000010 HPWL: 3046720
35-
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000009 HPWL: 74872
36-
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000008 HPWL: 61495
37-
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000011 HPWL: 61497
38-
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000011 HPWL: 61495
35+
[InitialPlace] Iter: 2 conjugate gradient residual: 0.00000009 HPWL: 74682
36+
[InitialPlace] Iter: 3 conjugate gradient residual: 0.00000008 HPWL: 61445
37+
[InitialPlace] Iter: 4 conjugate gradient residual: 0.00000011 HPWL: 61447
38+
[InitialPlace] Iter: 5 conjugate gradient residual: 0.00000011 HPWL: 61445
3939
Placement Analysis
4040
---------------------------------
41-
total displacement 6730.6 u
41+
total displacement 6730.7 u
4242
average displacement 23.8 u
4343
max displacement 35.5 u
44-
original HPWL 0.8 u
44+
original HPWL 0.9 u
4545
legalized HPWL 388.7 u
46-
delta HPWL 49070 %
46+
delta HPWL 44019 %
4747

4848
[INFO CTS-0050] Root buffer is CLKBUF_X3.
4949
[INFO CTS-0051] Sink buffer is CLKBUF_X3.

src/gpl/src/nesterovBase.cpp

Lines changed: 182 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void GCell::updateLocations()
125125
bbox.mergeInit();
126126
int64_t inst_area = 0;
127127
for (Instance* inst : insts_) {
128-
inst_area += inst->area();
128+
inst_area += inst->getArea();
129129
bbox.merge({inst->lx(), inst->ly(), inst->ux(), inst->uy()});
130130
}
131131
odb::Rect core_area = insts_[0]->dbInst()->getBlock()->getCoreArea();
@@ -1070,6 +1070,11 @@ NesterovBaseCommon::NesterovBaseCommon(NesterovBaseVars nbVars,
10701070
}
10711071
}
10721072

1073+
// Instance extension from pin density done in placerBase construction
1074+
if (log_->debugCheck(GPL, "extendPinDensity", 1)) {
1075+
reportInstanceExtensionByPinDensity();
1076+
}
1077+
10731078
// TODO:
10741079
// at this moment, GNet and GPin is equal to
10751080
// Net and Pin
@@ -1516,7 +1521,7 @@ void NesterovBaseCommon::revertGCellSizeToMinRc()
15161521
int dx = rect.dx();
15171522
int dy = rect.dy();
15181523

1519-
if (rect.area() > gCell->insts()[0]->area()) {
1524+
if (rect.area() > gCell->insts()[0]->getArea()) {
15201525
gCell->setSize(dx, dy, GCell::GCellChange::kRoutability);
15211526
} else {
15221527
gCell->setSize(dx, dy, GCell::GCellChange::kNone);
@@ -1683,6 +1688,179 @@ void NesterovBaseCommon::fixPointers()
16831688
}
16841689
}
16851690

1691+
void NesterovBaseCommon::reportInstanceExtensionByPinDensity() const
1692+
{
1693+
int64_t total_original_area = 0;
1694+
int64_t total_extended_area = 0;
1695+
int64_t total_area_diff = 0;
1696+
int increased_instance_count = 0;
1697+
int64_t increased_area = 0;
1698+
int decreased_instance_count = 0;
1699+
int64_t decreased_area = 0;
1700+
int unchanged_instance_count = 0;
1701+
int total_instance_count = 0;
1702+
struct MasterStats
1703+
{
1704+
int instance_count = 0;
1705+
int pin_count = 0;
1706+
double total_original_area = 0;
1707+
double total_extended_area = 0;
1708+
float original_area_per_pin = 0.0;
1709+
float extended_area_per_pin = 0.0;
1710+
float area_diff = 0.0;
1711+
};
1712+
static std::unordered_map<std::string, struct MasterStats> master_stats_map;
1713+
1714+
odb::dbBlock* block = pbc_->db()->getChip()->getBlock();
1715+
1716+
for (const GCell& gcell : gCellStor_) {
1717+
if (!gcell.isInstance()) {
1718+
continue;
1719+
}
1720+
odb::dbInst* db_inst = gcell.insts()[0]->dbInst();
1721+
odb::dbBox* bbox = db_inst->getBBox();
1722+
if (!bbox) {
1723+
continue;
1724+
}
1725+
++total_instance_count;
1726+
int orig_dx = bbox->getDX();
1727+
int orig_dy = bbox->getDY();
1728+
int64_t orig_area
1729+
= static_cast<int64_t>(orig_dx) * static_cast<int64_t>(orig_dy);
1730+
1731+
int ext_dx = gcell.ux() - gcell.lx();
1732+
int ext_dy = gcell.uy() - gcell.ly();
1733+
int64_t ext_area
1734+
= static_cast<int64_t>(ext_dx) * static_cast<int64_t>(ext_dy);
1735+
1736+
total_original_area += orig_area;
1737+
total_extended_area += ext_area;
1738+
int64_t area_diff = ext_area - orig_area;
1739+
total_area_diff += area_diff;
1740+
1741+
if (area_diff > 0) {
1742+
++increased_instance_count;
1743+
increased_area += area_diff;
1744+
} else if (area_diff < 0) {
1745+
++decreased_instance_count;
1746+
decreased_area += -area_diff;
1747+
} else {
1748+
++unchanged_instance_count;
1749+
}
1750+
1751+
// Collect per-master statistics
1752+
odb::dbMaster* master = db_inst->getMaster();
1753+
std::string master_name = master->getName();
1754+
auto& stats = master_stats_map[master_name];
1755+
stats.instance_count += 1;
1756+
if (stats.pin_count == 0) {
1757+
stats.pin_count = db_inst->getITerms().size();
1758+
}
1759+
stats.total_original_area = block->dbuAreaToMicrons(orig_area);
1760+
stats.total_extended_area = block->dbuAreaToMicrons(ext_area);
1761+
1762+
// Save area per pin
1763+
int pin_count = db_inst->getITerms().size();
1764+
if (pin_count > 0) {
1765+
stats.original_area_per_pin
1766+
= block->dbuAreaToMicrons(orig_area) / pin_count;
1767+
stats.extended_area_per_pin
1768+
= block->dbuAreaToMicrons(ext_area) / pin_count;
1769+
}
1770+
// Populate area_diff as the percentage difference between extended and
1771+
// original area
1772+
if (orig_area != 0) {
1773+
stats.area_diff = 100.0f
1774+
* (static_cast<float>(ext_area - orig_area)
1775+
/ static_cast<float>(orig_area));
1776+
} else {
1777+
stats.area_diff = 0.0f;
1778+
}
1779+
}
1780+
1781+
// Log per-master statistics
1782+
log_->report("NB Per-master statistics:");
1783+
for (const auto& entry : master_stats_map) {
1784+
const std::string& master_name = entry.first;
1785+
const MasterStats& stats = entry.second;
1786+
log_->report(
1787+
" Master: {} | Instances: {} | Pins: {} | Total original area: {} "
1788+
"um^2 | Total extended area: {} um^2 | Area diff: {:.2f}% | Original "
1789+
"area/pin: {:.4f} um^2 | Extended area/pin: {:.4f} um^2",
1790+
master_name,
1791+
stats.instance_count,
1792+
stats.pin_count,
1793+
stats.total_original_area,
1794+
stats.total_extended_area,
1795+
stats.area_diff,
1796+
stats.original_area_per_pin,
1797+
stats.extended_area_per_pin);
1798+
}
1799+
1800+
// Write per-master statistics to CSV
1801+
const std::string csv_filename = "inflation_stats.csv";
1802+
std::ofstream csv_file(csv_filename, std::ios::out);
1803+
if (csv_file.is_open()) {
1804+
csv_file << "master_name,instance_count,pin_count,total_original_area_um2,"
1805+
"total_extended_area_um2,area_diff_percent,original_area_per_"
1806+
"pin_um2,extended_area_per_pin_um2\n";
1807+
for (const auto& entry : master_stats_map) {
1808+
const std::string& master_name = entry.first;
1809+
const MasterStats& stats = entry.second;
1810+
csv_file << master_name << "," << stats.instance_count << ","
1811+
<< stats.pin_count << "," << stats.total_original_area << ","
1812+
<< stats.total_extended_area << "," << stats.area_diff << ","
1813+
<< stats.original_area_per_pin << ","
1814+
<< stats.extended_area_per_pin << "\n";
1815+
}
1816+
csv_file.close();
1817+
}
1818+
1819+
log_->report("NB Total original area: {} um^2",
1820+
block->dbuAreaToMicrons(total_original_area));
1821+
log_->report("NB Total extended area: {} um^2",
1822+
block->dbuAreaToMicrons(total_extended_area));
1823+
log_->report("NB Total area difference (extended - original): {} um^2",
1824+
block->dbuAreaToMicrons(total_area_diff));
1825+
log_->report("NB Total area increased: {} um^2 ({} instances)",
1826+
block->dbuAreaToMicrons(increased_area),
1827+
increased_instance_count);
1828+
log_->report("NB Total area decreased: {} um^2 ({} instances)",
1829+
block->dbuAreaToMicrons(decreased_area),
1830+
decreased_instance_count);
1831+
log_->report(
1832+
"NB Total area modified (sum of increases and decreases): {} um^2",
1833+
block->dbuAreaToMicrons(increased_area + decreased_area));
1834+
if (total_original_area != 0) {
1835+
double rel_diff = static_cast<double>(total_area_diff)
1836+
/ static_cast<double>(total_original_area);
1837+
log_->report("NB Relative area difference: {:.2f}%%", rel_diff * 100.0);
1838+
}
1839+
log_->report("NB Number of instances with increased area: {}",
1840+
increased_instance_count);
1841+
log_->report("NB Number of instances with decreased area: {}",
1842+
decreased_instance_count);
1843+
log_->report("NB Number of instances with unchanged area: {}",
1844+
unchanged_instance_count);
1845+
if (total_instance_count != 0) {
1846+
double percent_increased = static_cast<double>(increased_instance_count)
1847+
/ static_cast<double>(total_instance_count)
1848+
* 100.0;
1849+
double percent_decreased = static_cast<double>(decreased_instance_count)
1850+
/ static_cast<double>(total_instance_count)
1851+
* 100.0;
1852+
double percent_unchanged = static_cast<double>(unchanged_instance_count)
1853+
/ static_cast<double>(total_instance_count)
1854+
* 100.0;
1855+
log_->report("NB Percentage of instances with increased area: {:.2f}%%",
1856+
percent_increased);
1857+
log_->report("NB Percentage of instances with decreased area: {:.2f}%%",
1858+
percent_decreased);
1859+
log_->report("NB Percentage of instances with unchanged area: {:.2f}%%",
1860+
percent_unchanged);
1861+
}
1862+
}
1863+
16861864
////////////////////////////////////////////////
16871865
// NesterovBase
16881866

@@ -3275,9 +3453,9 @@ void NesterovBase::createCbkGCell(odb::dbInst* db_inst, size_t stor_index)
32753453
size_t NesterovBaseCommon::createCbkGCell(odb::dbInst* db_inst)
32763454
{
32773455
debugPrint(log_, GPL, "callbacks", 2, "NBC createCbkGCell");
3278-
Instance gpl_inst(db_inst, pbc_.get(), log_);
3456+
Instance pb_inst(db_inst, pbc_.get(), log_);
32793457

3280-
pb_insts_stor_.push_back(gpl_inst);
3458+
pb_insts_stor_.push_back(pb_inst);
32813459
GCell gcell(&pb_insts_stor_.back());
32823460
gCellStor_.push_back(gcell);
32833461
minRcCellSize_.emplace_back(gcell.lx(), gcell.ly(), gcell.ux(), gcell.uy());

src/gpl/src/nesterovBase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ class NesterovBaseCommon
801801
int num_threads,
802802
const Clusters& clusters);
803803

804+
void reportInstanceExtensionByPinDensity() const;
804805
const std::vector<GCell*>& getGCells() const { return nbc_gcells_; }
805806
const std::vector<GNet*>& getGNets() const { return gNets_; }
806807
const std::vector<GPin*>& getGPins() const { return gPins_; }

0 commit comments

Comments
 (0)