Skip to content

Commit e793e21

Browse files
remove std::max calls
1 parent 4a5c1c9 commit e793e21

File tree

1 file changed

+30
-31
lines changed

1 file changed

+30
-31
lines changed

vpr/src/place/net_cost_handler.cpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
#include <array>
3838

39-
using std::max;
4039
using std::min;
4140

4241

@@ -572,12 +571,12 @@ void NetCostHandler::get_non_updatable_cube_bb_(ClusterNetId net_id, bool use_ts
572571
* clip to 1 in both directions as well (since minimum channel index *
573572
* is 0). See route_common.cpp for a channel diagram. */
574573

575-
bb_coord_new.xmin = max(min<int>(xmin, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
576-
bb_coord_new.ymin = max(min<int>(ymin, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
577-
bb_coord_new.layer_min = max(min<int>(layer_min, device_ctx.grid.get_num_layers() - 1), 0);
578-
bb_coord_new.xmax = max(min<int>(xmax, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
579-
bb_coord_new.ymax = max(min<int>(ymax, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
580-
bb_coord_new.layer_max = max(min<int>(layer_max, device_ctx.grid.get_num_layers() - 1), 0);
574+
bb_coord_new.xmin = min<int>(xmin, device_ctx.grid.width() - 2); //-2 for no perim channels
575+
bb_coord_new.ymin = min<int>(ymin, device_ctx.grid.height() - 2); //-2 for no perim channels
576+
bb_coord_new.layer_min = layer_min;
577+
bb_coord_new.xmax = min<int>(xmax, device_ctx.grid.width() - 2); //-2 for no perim channels
578+
bb_coord_new.ymax = min<int>(ymax, device_ctx.grid.height() - 2); //-2 for no perim channels
579+
bb_coord_new.layer_max = layer_max;
581580
}
582581

583582
void NetCostHandler::get_non_updatable_per_layer_bb_(ClusterNetId net_id, bool use_ts) {
@@ -637,10 +636,10 @@ void NetCostHandler::get_non_updatable_per_layer_bb_(ClusterNetId net_id, bool u
637636
* is 0). See route_common.cpp for a channel diagram. */
638637
for (int layer_num = 0; layer_num < num_layers; layer_num++) {
639638
bb_coord_new[layer_num].layer_num = layer_num;
640-
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
641-
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
642-
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
643-
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
639+
bb_coord_new[layer_num].xmin = min<int>(bb_coord_new[layer_num].xmin, device_ctx.grid.width() - 2); //-2 for no perim channels
640+
bb_coord_new[layer_num].ymin = min<int>(bb_coord_new[layer_num].ymin, device_ctx.grid.height() - 2); //-2 for no perim channels
641+
bb_coord_new[layer_num].xmax = min<int>(bb_coord_new[layer_num].xmax, device_ctx.grid.width() - 2); //-2 for no perim channels
642+
bb_coord_new[layer_num].ymax = min<int>(bb_coord_new[layer_num].ymax, device_ctx.grid.height() - 2); //-2 for no perim channels
644643
}
645644
}
646645

@@ -663,12 +662,12 @@ void NetCostHandler::update_bb_(ClusterNetId net_id,
663662
// Number of sinks of the given net on each layer
664663
vtr::NdMatrixProxy<int, 1> num_sink_pin_layer_new = ts_layer_sink_pin_count_[size_t(net_id)];
665664

666-
pin_new_loc.x = max(min<int>(pin_new_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
667-
pin_new_loc.y = max(min<int>(pin_new_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
668-
pin_new_loc.layer_num = max(min<int>(pin_new_loc.layer_num, device_ctx.grid.get_num_layers() - 1), 0);
669-
pin_old_loc.x = max(min<int>(pin_old_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
670-
pin_old_loc.y = max(min<int>(pin_old_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
671-
pin_old_loc.layer_num = max(min<int>(pin_old_loc.layer_num, device_ctx.grid.get_num_layers() - 1), 0);
665+
pin_new_loc.x = min<int>(pin_new_loc.x, device_ctx.grid.width() - 2); //-2 for no perim channels
666+
pin_new_loc.y = min<int>(pin_new_loc.y, device_ctx.grid.height() - 2); //-2 for no perim channels
667+
pin_new_loc.layer_num = pin_new_loc.layer_num;
668+
pin_old_loc.x = min<int>(pin_old_loc.x, device_ctx.grid.width() - 2); //-2 for no perim channels
669+
pin_old_loc.y = min<int>(pin_old_loc.y, device_ctx.grid.height() - 2); //-2 for no perim channels
670+
pin_old_loc.layer_num = pin_old_loc.layer_num;
672671

673672
/* Check if the net had been updated before. */
674673
if (bb_update_status_[net_id] == NetUpdateState::GOT_FROM_SCRATCH) {
@@ -927,10 +926,10 @@ void NetCostHandler::update_layer_bb_(ClusterNetId net_id,
927926
auto& device_ctx = g_vpr_ctx.device();
928927
auto& place_move_ctx = placer_state_.move();
929928

930-
pin_new_loc.x = max(min<int>(pin_new_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
931-
pin_new_loc.y = max(min<int>(pin_new_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
932-
pin_old_loc.x = max(min<int>(pin_old_loc.x, device_ctx.grid.width() - 2), 1); //-2 for no perim channels
933-
pin_old_loc.y = max(min<int>(pin_old_loc.y, device_ctx.grid.height() - 2), 1); //-2 for no perim channels
929+
pin_new_loc.x = min<int>(pin_new_loc.x, device_ctx.grid.width() - 2); //-2 for no perim channels
930+
pin_new_loc.y = min<int>(pin_new_loc.y, device_ctx.grid.height() - 2); //-2 for no perim channels
931+
pin_old_loc.x = min<int>(pin_old_loc.x, device_ctx.grid.width() - 2); //-2 for no perim channels
932+
pin_old_loc.y = min<int>(pin_old_loc.y, device_ctx.grid.height() - 2); //-2 for no perim channels
934933

935934
std::vector<t_2D_bb>& bb_edge_new = layer_ts_bb_edge_new_[net_id];
936935
std::vector<t_2D_bb>& bb_coord_new = layer_ts_bb_coord_new_[net_id];
@@ -1285,9 +1284,9 @@ void NetCostHandler::get_bb_from_scratch_(ClusterNetId net_id,
12851284
int y = block_loc.y + physical_tile_type(block_loc)->pin_height_offset[pnum];
12861285
int pin_layer = block_loc.layer;
12871286

1288-
x = max(min<int>(x, grid.width() - 2), 1);
1289-
y = max(min<int>(y, grid.height() - 2), 1);
1290-
pin_layer = max(min<int>(pin_layer, grid.get_num_layers() - 1), 0);
1287+
x = min<int>(x, grid.width() - 2);
1288+
y = min<int>(y, grid.height() - 2);
1289+
pin_layer = min<int>(pin_layer, grid.get_num_layers() - 1);
12911290

12921291
int xmin = x;
12931292
int ymin = y;
@@ -1322,9 +1321,9 @@ void NetCostHandler::get_bb_from_scratch_(ClusterNetId net_id,
13221321
* the which channels are included within the bounding box, and it *
13231322
* simplifies the code a lot. */
13241323

1325-
x = max(min<int>(x, grid.width() - 2), 1); //-2 for no perim channels
1326-
y = max(min<int>(y, grid.height() - 2), 1); //-2 for no perim channels
1327-
pin_layer = max(min<int>(pin_layer, grid.get_num_layers() - 1), 0);
1324+
x = min<int>(x, grid.width() - 2); //-2 for no perim channels
1325+
y = min<int>(y, grid.height() - 2); //-2 for no perim channels
1326+
pin_layer = min<int>(pin_layer, grid.get_num_layers() - 1);
13281327

13291328
if (x == xmin) {
13301329
xmin_edge++;
@@ -1406,8 +1405,8 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
14061405
int x_src = block_loc.x + physical_tile_type(block_loc)->pin_width_offset[pnum_src];
14071406
int y_src = block_loc.y + physical_tile_type(block_loc)->pin_height_offset[pnum_src];
14081407

1409-
x_src = max(min<int>(x_src, grid.width() - 2), 1);
1410-
y_src = max(min<int>(y_src, grid.height() - 2), 1);
1408+
x_src = min<int>(x_src, grid.width() - 2);
1409+
y_src = min<int>(y_src, grid.height() - 2);
14111410

14121411
// TODO: Currently we are assuming that crossing can only happen from OPIN. Because of that,
14131412
// when per-layer bounding box is used, we want the bounding box on each layer to also include
@@ -1435,8 +1434,8 @@ void NetCostHandler::get_layer_bb_from_scratch_(ClusterNetId net_id,
14351434
* the which channels are included within the bounding box, and it *
14361435
* simplifies the code a lot. */
14371436

1438-
x = max(min<int>(x, grid.width() - 2), 1); //-2 for no perim channels
1439-
y = max(min<int>(y, grid.height() - 2), 1); //-2 for no perim channels
1437+
x = min<int>(x, grid.width() - 2); //-2 for no perim channels
1438+
y = min<int>(y, grid.height() - 2); //-2 for no perim channels
14401439

14411440
if (x == coords[layer].xmin) {
14421441
num_on_edges[layer].xmin++;

0 commit comments

Comments
 (0)