34
34
#include " noc_place_utils.h"
35
35
#include " vtr_math.h"
36
36
37
- #include < optional>
38
- #include < functional>
39
-
40
37
using std::max;
41
38
using std::min;
42
39
@@ -58,23 +55,6 @@ static const float cross_count[MAX_FANOUT_CROSSING_COUNT] = {/* [0..49] */ 1.0,
58
55
2.5610 , 2.5864 , 2.6117 , 2.6371 , 2.6625 , 2.6887 , 2.7148 , 2.7410 , 2.7671 ,
59
56
2.7933 };
60
57
61
- /* *
62
- * @brief Matrices below are used to precompute the inverse of the average
63
- * number of tracks per channel between [subhigh] and [sublow]. Access
64
- * them as chan?_place_cost_fac[subhigh][sublow]. They are used to
65
- * speed up the computation of the cost function that takes the length
66
- * of the net bounding box in each dimension, divided by the average
67
- * number of tracks in that direction; for other cost functions they
68
- * will never be used.
69
- */
70
- static vtr::NdMatrix<float , 2 > chanx_place_cost_fac ({0 , 0 }); // [0...device_ctx.grid.width()-2]
71
- static vtr::NdMatrix<float , 2 > chany_place_cost_fac ({0 , 0 }); // [0...device_ctx.grid.height()-2]
72
-
73
- namespace {
74
-
75
-
76
- } // namespace
77
-
78
58
/* *
79
59
* @param net
80
60
* @param moved_blocks
@@ -83,17 +63,6 @@ namespace {
83
63
static bool driven_by_moved_block (const ClusterNetId net,
84
64
const std::vector<t_pl_moved_block>& moved_blocks);
85
65
86
- /* *
87
- * @brief Given the per-layer BB, calculate the wire-length cost of the net on each layer
88
- * and return the sum of the costs
89
- * @param net_id ID of the net which cost is requested
90
- * @param bb Per-layer bounding box of the net
91
- * @return Wirelength cost of the net
92
- */
93
- static double get_net_layer_bb_wire_cost (ClusterNetId /* net_id */ ,
94
- const std::vector<t_2D_bb>& bb,
95
- const vtr::NdMatrixProxy<int , 1 > layer_pin_sink_count);
96
-
97
66
/* *
98
67
* @brief Given the per-layer BB, calculate the wire-length estimate of the net on each layer
99
68
* and return the sum of the lengths
@@ -138,13 +107,7 @@ static void add_block_to_bb(const t_physical_tile_loc& new_pin_loc,
138
107
t_2D_bb& bb_edge_new,
139
108
t_2D_bb& bb_coord_new);
140
109
141
- /* *
142
- * @brief Given the 3D BB, calculate the wire-length cost of the net
143
- * @param net_id ID of the net which cost is requested
144
- * @param bb Bounding box of the net
145
- * @return Wirelength cost of the net
146
- */
147
- static double get_net_cost (ClusterNetId net_id, const t_bb& bb);
110
+
148
111
149
112
/* *
150
113
* @brief Given the 3D BB, calculate the wire-length estimate of the net
@@ -621,7 +584,7 @@ void NetCostHandler::update_bb_(ClusterNetId net_id,
621
584
bb_edge_new.ymax = curr_bb_edge->ymax - 1 ;
622
585
bb_coord_new.ymax = curr_bb_coord->ymax ;
623
586
}
624
- } else { /* Move down, old postion was not at ymax. */
587
+ } else { /* Move down, old position was not at ymax. */
625
588
bb_coord_new.ymax = curr_bb_coord->ymax ;
626
589
bb_edge_new.ymax = curr_bb_edge->ymax ;
627
590
}
@@ -1340,7 +1303,7 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
1340
1303
}
1341
1304
}
1342
1305
1343
- static double get_net_cost (ClusterNetId net_id, const t_bb& bb) {
1306
+ double NetCostHandler::get_net_cost_ (ClusterNetId net_id, const t_bb& bb) {
1344
1307
/* Finds the cost due to one net by looking at its coordinate bounding *
1345
1308
* box. */
1346
1309
auto & cluster_ctx = g_vpr_ctx.clustering ();
@@ -1355,15 +1318,15 @@ static double get_net_cost(ClusterNetId net_id, const t_bb& bb) {
1355
1318
* channel capacity. Do this for x, then y direction and add. */
1356
1319
1357
1320
double ncost;
1358
- ncost = (bb.xmax - bb.xmin + 1 ) * crossing * chanx_place_cost_fac [bb.ymax ][bb.ymin - 1 ];
1359
- ncost += (bb.ymax - bb.ymin + 1 ) * crossing * chany_place_cost_fac [bb.xmax ][bb.xmin - 1 ];
1321
+ ncost = (bb.xmax - bb.xmin + 1 ) * crossing * chanx_place_cost_fac_ [bb.ymax ][bb.ymin - 1 ];
1322
+ ncost += (bb.ymax - bb.ymin + 1 ) * crossing * chany_place_cost_fac_ [bb.xmax ][bb.xmin - 1 ];
1360
1323
1361
1324
return (ncost);
1362
1325
}
1363
1326
1364
- static double get_net_layer_bb_wire_cost (ClusterNetId /* net_id */ ,
1365
- const std::vector<t_2D_bb>& bb,
1366
- const vtr::NdMatrixProxy<int , 1 > layer_pin_sink_count) {
1327
+ double NetCostHandler::get_net_layer_bb_wire_cost_ (ClusterNetId /* net_id */ ,
1328
+ const std::vector<t_2D_bb>& bb,
1329
+ const vtr::NdMatrixProxy<int , 1 > layer_pin_sink_count) {
1367
1330
/* Finds the cost due to one net by looking at its coordinate bounding *
1368
1331
* box. */
1369
1332
@@ -1391,10 +1354,10 @@ static double get_net_layer_bb_wire_cost(ClusterNetId /* net_id */,
1391
1354
* channel capacity. Do this for x, then y direction and add. */
1392
1355
1393
1356
ncost += (bb[layer_num].xmax - bb[layer_num].xmin + 1 ) * crossing
1394
- * chanx_place_cost_fac [bb[layer_num].ymax ][bb[layer_num].ymin - 1 ];
1357
+ * chanx_place_cost_fac_ [bb[layer_num].ymax ][bb[layer_num].ymin - 1 ];
1395
1358
1396
1359
ncost += (bb[layer_num].ymax - bb[layer_num].ymin + 1 ) * crossing
1397
- * chany_place_cost_fac [bb[layer_num].xmax ][bb[layer_num].xmin - 1 ];
1360
+ * chany_place_cost_fac_ [bb[layer_num].xmax ][bb[layer_num].xmin - 1 ];
1398
1361
}
1399
1362
1400
1363
return (ncost);
@@ -1414,7 +1377,6 @@ static double get_net_wirelength_estimate(ClusterNetId net_id, const t_bb& bb) {
1414
1377
1415
1378
double ncost;
1416
1379
ncost = (bb.xmax - bb.xmin + 1 ) * crossing;
1417
-
1418
1380
ncost += (bb.ymax - bb.ymin + 1 ) * crossing;
1419
1381
1420
1382
return ncost;
@@ -1555,7 +1517,7 @@ double NetCostHandler::comp_3d_bb_cost_(e_cost_methods method) {
1555
1517
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
1556
1518
}
1557
1519
1558
- net_cost_[net_id] = get_net_cost (net_id, place_move_ctx.bb_coords [net_id]);
1520
+ net_cost_[net_id] = get_net_cost_ (net_id, place_move_ctx.bb_coords [net_id]);
1559
1521
cost += net_cost_[net_id];
1560
1522
if (method == e_cost_methods::CHECK)
1561
1523
expected_wirelength += get_net_wirelength_estimate (net_id, place_move_ctx.bb_coords [net_id]);
@@ -1591,7 +1553,7 @@ double NetCostHandler::comp_per_layer_bb_cost_(e_cost_methods method) {
1591
1553
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
1592
1554
}
1593
1555
1594
- net_cost_[net_id] = get_net_layer_bb_wire_cost (net_id,
1556
+ net_cost_[net_id] = get_net_layer_bb_wire_cost_ (net_id,
1595
1557
place_move_ctx.layer_bb_coords [net_id],
1596
1558
place_move_ctx.num_sink_pin_layer [size_t (net_id)]);
1597
1559
cost += net_cost_[net_id];
@@ -1730,18 +1692,18 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
1730
1692
for simplicity so we can use the vtr utility matrix functions.
1731
1693
*/
1732
1694
1733
- chanx_place_cost_fac .resize ({device_ctx.grid .height (), device_ctx.grid .height () + 1 });
1734
- chany_place_cost_fac .resize ({device_ctx.grid .width (), device_ctx.grid .width () + 1 });
1695
+ chanx_place_cost_fac_ .resize ({device_ctx.grid .height (), device_ctx.grid .height () + 1 });
1696
+ chany_place_cost_fac_ .resize ({device_ctx.grid .width (), device_ctx.grid .width () + 1 });
1735
1697
1736
1698
/* First compute the number of tracks between channel high and channel *
1737
1699
* low, inclusive, in an efficient manner. */
1738
1700
1739
- chanx_place_cost_fac [0 ][0 ] = device_ctx.chan_width .x_list [0 ];
1701
+ chanx_place_cost_fac_ [0 ][0 ] = device_ctx.chan_width .x_list [0 ];
1740
1702
1741
1703
for (size_t high = 1 ; high < device_ctx.grid .height (); high++) {
1742
- chanx_place_cost_fac [high][high] = device_ctx.chan_width .x_list [high];
1704
+ chanx_place_cost_fac_ [high][high] = device_ctx.chan_width .x_list [high];
1743
1705
for (size_t low = 0 ; low < high; low++) {
1744
- chanx_place_cost_fac [high][low] = chanx_place_cost_fac [high - 1 ][low] + device_ctx.chan_width .x_list [high];
1706
+ chanx_place_cost_fac_ [high][low] = chanx_place_cost_fac_ [high - 1 ][low] + device_ctx.chan_width .x_list [high];
1745
1707
}
1746
1708
}
1747
1709
@@ -1760,27 +1722,24 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
1760
1722
* will result in infinite wiring capacity normalization *
1761
1723
* factor, and extremely bad placer behaviour. Hence we change *
1762
1724
* this to a small (1 track) channel capacity instead. */
1763
- if (chanx_place_cost_fac [high][low] == 0 .0f ) {
1725
+ if (chanx_place_cost_fac_ [high][low] == 0 .0f ) {
1764
1726
VTR_LOG_WARN (" CHANX place cost fac is 0 at %d %d\n " , high, low);
1765
- chanx_place_cost_fac [high][low] = 1 .0f ;
1727
+ chanx_place_cost_fac_ [high][low] = 1 .0f ;
1766
1728
}
1767
1729
1768
- chanx_place_cost_fac[high][low] = (high - low + 1 .)
1769
- / chanx_place_cost_fac[high][low];
1770
- chanx_place_cost_fac[high][low] = pow (
1771
- (double )chanx_place_cost_fac[high][low],
1772
- (double )place_cost_exp);
1730
+ chanx_place_cost_fac_[high][low] = (high - low + 1 .) / chanx_place_cost_fac_[high][low];
1731
+ chanx_place_cost_fac_[high][low] = pow ((double )chanx_place_cost_fac_[high][low], (double )place_cost_exp);
1773
1732
}
1774
1733
1775
1734
/* Now do the same thing for the y-directed channels. First get the *
1776
1735
* number of tracks between channel high and channel low, inclusive. */
1777
1736
1778
- chany_place_cost_fac [0 ][0 ] = device_ctx.chan_width .y_list [0 ];
1737
+ chany_place_cost_fac_ [0 ][0 ] = device_ctx.chan_width .y_list [0 ];
1779
1738
1780
1739
for (size_t high = 1 ; high < device_ctx.grid .width (); high++) {
1781
- chany_place_cost_fac [high][high] = device_ctx.chan_width .y_list [high];
1740
+ chany_place_cost_fac_ [high][high] = device_ctx.chan_width .y_list [high];
1782
1741
for (size_t low = 0 ; low < high; low++) {
1783
- chany_place_cost_fac [high][low] = chany_place_cost_fac [high - 1 ][low] + device_ctx.chan_width .y_list [high];
1742
+ chany_place_cost_fac_ [high][low] = chany_place_cost_fac_ [high - 1 ][low] + device_ctx.chan_width .y_list [high];
1784
1743
}
1785
1744
}
1786
1745
@@ -1794,23 +1753,16 @@ void NetCostHandler::alloc_and_load_chan_w_factors_for_place_cost_(float place_c
1794
1753
* will result in infinite wiring capacity normalization *
1795
1754
* factor, and extremely bad placer behaviour. Hence we change *
1796
1755
* this to a small (1 track) channel capacity instead. */
1797
- if (chany_place_cost_fac [high][low] == 0 .0f ) {
1756
+ if (chany_place_cost_fac_ [high][low] == 0 .0f ) {
1798
1757
VTR_LOG_WARN (" CHANY place cost fac is 0 at %d %d\n " , high, low);
1799
- chany_place_cost_fac [high][low] = 1 .0f ;
1758
+ chany_place_cost_fac_ [high][low] = 1 .0f ;
1800
1759
}
1801
1760
1802
- chany_place_cost_fac[high][low] = (high - low + 1 .) / chany_place_cost_fac[high][low];
1803
- chany_place_cost_fac[high][low] = pow (
1804
- (double )chany_place_cost_fac[high][low],
1805
- (double )place_cost_exp);
1761
+ chany_place_cost_fac_[high][low] = (high - low + 1 .) / chany_place_cost_fac_[high][low];
1762
+ chany_place_cost_fac_[high][low] = pow ((double )chany_place_cost_fac_[high][low], (double )place_cost_exp);
1806
1763
}
1807
1764
}
1808
1765
1809
- void NetCostHandler::free_chan_w_factors_for_place_cost () {
1810
- chanx_place_cost_fac.clear ();
1811
- chany_place_cost_fac.clear ();
1812
- }
1813
-
1814
1766
NetCostHandler::NetCostHandler (PlacerContext& placer_ctx, size_t num_nets, bool cube_bb, float place_cost_exp)
1815
1767
: cube_bb_(cube_bb)
1816
1768
, placer_ctx_(placer_ctx) {
@@ -1879,10 +1831,10 @@ void NetCostHandler::update_bb_(ClusterNetId net_id, t_physical_tile_loc pin_old
1879
1831
1880
1832
double NetCostHandler::get_net_cost_ (const ClusterNetId net_id) {
1881
1833
if (cube_bb_) {
1882
- return :: get_net_cost (net_id, ts_bb_coord_new_[net_id]);
1834
+ return get_net_cost_ (net_id, ts_bb_coord_new_[net_id]);
1883
1835
}
1884
1836
else {
1885
- return :: get_net_layer_bb_wire_cost (net_id, layer_ts_bb_coord_new_[net_id], ts_layer_sink_pin_count_[size_t (net_id)]);
1837
+ return get_net_layer_bb_wire_cost_ (net_id, layer_ts_bb_coord_new_[net_id], ts_layer_sink_pin_count_[size_t (net_id)]);
1886
1838
}
1887
1839
}
1888
1840
0 commit comments