Skip to content

Commit cd005be

Browse files
remove local vectors in get_non_updatable_layer_bb_() and get_layer_bb_from_scratch_()
1 parent 6fa0520 commit cd005be

File tree

1 file changed

+50
-81
lines changed

1 file changed

+50
-81
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 50 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -600,17 +600,15 @@ void NetCostHandler::get_non_updatable_bb_(ClusterNetId net_id,
600600
}
601601

602602
void NetCostHandler::get_non_updatable_layer_bb_(ClusterNetId net_id,
603-
std::vector<t_2D_bb>& bb_coord_new,
604-
vtr::NdMatrixProxy<int, 1> num_sink_layer) {
603+
std::vector<t_2D_bb>& bb_coord_new,
604+
vtr::NdMatrixProxy<int, 1> num_sink_layer) {
605605
//TODO: account for multiple physical pin instances per logical pin
606606
auto& device_ctx = g_vpr_ctx.device();
607607
auto& cluster_ctx = g_vpr_ctx.clustering();
608608
auto& block_locs = placer_ctx_.block_locs();
609609

610-
int num_layers = device_ctx.grid.get_num_layers();
611-
for (int layer_num = 0; layer_num < device_ctx.grid.get_num_layers(); layer_num++) {
612-
num_sink_layer[layer_num] = 0;
613-
}
610+
const int num_layers = device_ctx.grid.get_num_layers();
611+
VTR_ASSERT_DEBUG(bb_coord_new.size() == num_layers);
614612

615613
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
616614
t_pl_loc block_loc = block_locs[bnum].loc;
@@ -619,10 +617,10 @@ void NetCostHandler::get_non_updatable_layer_bb_(ClusterNetId net_id,
619617
int src_x = block_locs[bnum].loc.x + physical_tile_type(block_loc)->pin_width_offset[pnum];
620618
int src_y = block_locs[bnum].loc.y + physical_tile_type(block_loc)->pin_height_offset[pnum];
621619

622-
std::vector<int> xmin(num_layers, src_x);
623-
std::vector<int> ymin(num_layers, src_y);
624-
std::vector<int> xmax(num_layers, src_x);
625-
std::vector<int> ymax(num_layers, src_y);
620+
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
621+
bb_coord_new[layer_num] = t_2D_bb{src_x, src_y, src_x, src_y, layer_num};
622+
num_sink_layer[layer_num] = 0;
623+
}
626624

627625
for (ClusterPinId pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
628626
bnum = cluster_ctx.clb_nlist.pin_block(pin_id);
@@ -633,16 +631,17 @@ void NetCostHandler::get_non_updatable_layer_bb_(ClusterNetId net_id,
633631

634632
int layer_num = block_locs[bnum].loc.layer;
635633
num_sink_layer[layer_num]++;
636-
if (x < xmin[layer_num]) {
637-
xmin[layer_num] = x;
638-
} else if (x > xmax[layer_num]) {
639-
xmax[layer_num] = x;
634+
635+
if (x < bb_coord_new[layer_num].xmin) {
636+
bb_coord_new[layer_num].xmin = x;
637+
} else if (x > bb_coord_new[layer_num].xmax) {
638+
bb_coord_new[layer_num].xmax = x;
640639
}
641640

642-
if (y < ymin[layer_num]) {
643-
ymin[layer_num] = y;
644-
} else if (y > ymax[layer_num]) {
645-
ymax[layer_num] = y;
641+
if (y < bb_coord_new[layer_num].ymin) {
642+
bb_coord_new[layer_num].ymin = y;
643+
} else if (y > bb_coord_new[layer_num].ymax) {
644+
bb_coord_new[layer_num].ymax = y;
646645
}
647646
}
648647

@@ -655,10 +654,10 @@ void NetCostHandler::get_non_updatable_layer_bb_(ClusterNetId net_id,
655654
* is 0). See route_common.cpp for a channel diagram. */
656655
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
657656
bb_coord_new[layer_num].layer_num = layer_num;
658-
bb_coord_new[layer_num].xmin = max(min<int>(xmin[layer_num], device_ctx.grid.width() - 2), 1); //-2 for no perim channels
659-
bb_coord_new[layer_num].ymin = max(min<int>(ymin[layer_num], device_ctx.grid.height() - 2), 1); //-2 for no perim channels
660-
bb_coord_new[layer_num].xmax = max(min<int>(xmax[layer_num], device_ctx.grid.width() - 2), 1); //-2 for no perim channels
661-
bb_coord_new[layer_num].ymax = max(min<int>(ymax[layer_num], device_ctx.grid.height() - 2), 1); //-2 for no perim channels
657+
bb_coord_new[layer_num].xmin = max(min<int>(bb_coord_new[layer_num].xmin, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
658+
bb_coord_new[layer_num].ymin = max(min<int>(bb_coord_new[layer_num].ymin, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
659+
bb_coord_new[layer_num].xmax = max(min<int>(bb_coord_new[layer_num].xmax, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
660+
bb_coord_new[layer_num].ymax = max(min<int>(bb_coord_new[layer_num].ymax, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
662661
}
663662
}
664663

@@ -1399,25 +1398,17 @@ void NetCostHandler::get_bb_from_scratch_(ClusterNetId net_id,
13991398
}
14001399

14011400
void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
1402-
std::vector<t_2D_bb>& num_on_edges,
1403-
std::vector<t_2D_bb>& coords,
1404-
vtr::NdMatrixProxy<int, 1> layer_pin_sink_count) {
1401+
std::vector<t_2D_bb>& num_on_edges,
1402+
std::vector<t_2D_bb>& coords,
1403+
vtr::NdMatrixProxy<int, 1> layer_pin_sink_count) {
14051404
auto& device_ctx = g_vpr_ctx.device();
14061405
auto& cluster_ctx = g_vpr_ctx.clustering();
14071406
auto& grid = device_ctx.grid;
14081407
auto& block_locs = placer_ctx_.block_locs();
14091408

14101409
const int num_layers = device_ctx.grid.get_num_layers();
1411-
std::vector<int> xmin(num_layers, OPEN);
1412-
std::vector<int> xmax(num_layers, OPEN);
1413-
std::vector<int> ymin(num_layers, OPEN);
1414-
std::vector<int> ymax(num_layers, OPEN);
1415-
std::vector<int> xmin_edge(num_layers, OPEN);
1416-
std::vector<int> xmax_edge(num_layers, OPEN);
1417-
std::vector<int> ymin_edge(num_layers, OPEN);
1418-
std::vector<int> ymax_edge(num_layers, OPEN);
1419-
1420-
std::vector<int> num_sink_pin_layer(num_layers, 0);
1410+
VTR_ASSERT_DEBUG(coords.size() == num_layers);
1411+
VTR_ASSERT_DEBUG(num_on_edges.size() == num_layers);
14211412

14221413
ClusterBlockId bnum = cluster_ctx.clb_nlist.net_driver_block(net_id);
14231414
t_pl_loc block_loc = block_locs[bnum].loc;
@@ -1433,14 +1424,9 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
14331424
// when per-layer bounding box is used, we want the bounding box on each layer to also include
14341425
// the location of source since the connection on each layer starts from that location.
14351426
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
1436-
xmin[layer_num] = x_src;
1437-
ymin[layer_num] = y_src;
1438-
xmax[layer_num] = x_src;
1439-
ymax[layer_num] = y_src;
1440-
xmin_edge[layer_num] = 1;
1441-
ymin_edge[layer_num] = 1;
1442-
xmax_edge[layer_num] = 1;
1443-
ymax_edge[layer_num] = 1;
1427+
coords[layer_num] = t_2D_bb{x_src, y_src, x_src, y_src, layer_num};
1428+
num_on_edges[layer_num] = t_2D_bb{1, 1, 1, 1, layer_num};
1429+
layer_pin_sink_count[layer_num] = 0;
14441430
}
14451431

14461432
for (ClusterPinId pin_id : cluster_ctx.clb_nlist.net_sinks(net_id)) {
@@ -1449,7 +1435,7 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
14491435
int pnum = placer_ctx_.blk_loc_registry().tile_pin_index(pin_id);
14501436
int layer = block_locs[bnum].loc.layer;
14511437
VTR_ASSERT_SAFE(layer >= 0 && layer < num_layers);
1452-
num_sink_pin_layer[layer]++;
1438+
layer_pin_sink_count[layer]++;
14531439
int x = block_loc.x + physical_tile_type(block_loc)->pin_width_offset[pnum];
14541440
int y = block_loc.y + physical_tile_type(block_loc)->pin_height_offset[pnum];
14551441

@@ -1463,49 +1449,32 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
14631449
x = max(min<int>(x, grid.width() - 2), 1); //-2 for no perim channels
14641450
y = max(min<int>(y, grid.height() - 2), 1); //-2 for no perim channels
14651451

1466-
if (x == xmin[layer]) {
1467-
xmin_edge[layer]++;
1452+
if (x == coords[layer].xmin) {
1453+
num_on_edges[layer].xmin++;
14681454
}
1469-
if (x == xmax[layer]) { /* Recall that xmin could equal xmax -- don't use else */
1470-
xmax_edge[layer]++;
1471-
} else if (x < xmin[layer]) {
1472-
xmin[layer] = x;
1473-
xmin_edge[layer] = 1;
1474-
} else if (x > xmax[layer]) {
1475-
xmax[layer] = x;
1476-
xmax_edge[layer] = 1;
1455+
if (x == coords[layer].xmax) { /* Recall that xmin could equal xmax -- don't use else */
1456+
num_on_edges[layer].xmax++;
1457+
} else if (x < coords[layer].xmin) {
1458+
coords[layer].xmin = x;
1459+
num_on_edges[layer].xmin = 1;
1460+
} else if (x > coords[layer].xmax) {
1461+
coords[layer].xmax = x;
1462+
num_on_edges[layer].xmax = 1;
14771463
}
14781464

1479-
if (y == ymin[layer]) {
1480-
ymin_edge[layer]++;
1465+
if (y == coords[layer].ymin) {
1466+
num_on_edges[layer].ymin++;
14811467
}
1482-
if (y == ymax[layer]) {
1483-
ymax_edge[layer]++;
1484-
} else if (y < ymin[layer]) {
1485-
ymin[layer] = y;
1486-
ymin_edge[layer] = 1;
1487-
} else if (y > ymax[layer]) {
1488-
ymax[layer] = y;
1489-
ymax_edge[layer] = 1;
1468+
if (y == coords[layer].ymax) {
1469+
num_on_edges[layer].ymax++;
1470+
} else if (y < coords[layer].ymin) {
1471+
coords[layer].ymin = y;
1472+
num_on_edges[layer].ymin = 1;
1473+
} else if (y > coords[layer].ymax) {
1474+
coords[layer].ymax = y;
1475+
num_on_edges[layer].ymax = 1;
14901476
}
14911477
}
1492-
1493-
/* Copy the coordinates and number on edges information into the proper *
1494-
* structures. */
1495-
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
1496-
layer_pin_sink_count[layer_num] = num_sink_pin_layer[layer_num];
1497-
coords[layer_num].xmin = xmin[layer_num];
1498-
coords[layer_num].xmax = xmax[layer_num];
1499-
coords[layer_num].ymin = ymin[layer_num];
1500-
coords[layer_num].ymax = ymax[layer_num];
1501-
coords[layer_num].layer_num = layer_num;
1502-
1503-
num_on_edges[layer_num].xmin = xmin_edge[layer_num];
1504-
num_on_edges[layer_num].xmax = xmax_edge[layer_num];
1505-
num_on_edges[layer_num].ymin = ymin_edge[layer_num];
1506-
num_on_edges[layer_num].ymax = ymax_edge[layer_num];
1507-
num_on_edges[layer_num].layer_num = layer_num;
1508-
}
15091478
}
15101479

15111480
double NetCostHandler::get_net_cost_(ClusterNetId net_id, const t_bb& bb) {

0 commit comments

Comments
 (0)