Skip to content

Commit 5cc1409

Browse files
use std::pair<int, int> instead of two int*
1 parent 36dacfa commit 5cc1409

File tree

6 files changed

+85
-97
lines changed

6 files changed

+85
-97
lines changed

libs/librrgraph/src/base/rr_graph_view.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class RRGraphView {
369369
/** @brief Get outgoing edges for a node.
370370
* This API is designed to enable range-based loop to walk through the outgoing edges of a node
371371
* Example:
372-
* RRGraphView rr_graph; // A dummny rr_graph for a short example
372+
* RRGraphView rr_graph; // A dummy rr_graph for a short example
373373
* RRNodeId node; // A dummy node for a short example
374374
* for (RREdgeId edge : rr_graph.edges(node)) {
375375
* // Do something with the edge
@@ -436,7 +436,7 @@ class RRGraphView {
436436
}
437437

438438
/** @brief Return the switch information that is categorized in the rr_switch_inf with a given id
439-
* rr_switch_inf is created to minimize memory footprint of RRGraph classs
439+
* rr_switch_inf is created to minimize memory footprint of RRGraph class
440440
* While the RRG could contain millions (even much larger) of edges, there are only
441441
* a limited number of types of switches.
442442
* Hence, we use a flyweight pattern to store switch-related information that differs

vpr/src/base/read_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,7 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio
25782578
" * classic: The classic VPR lookahead (may perform better on un-buffered routing\n"
25792579
" architectures)\n"
25802580
" * map: An advanced lookahead which accounts for diverse wire type\n"
2581-
" * compressed_map: The algorithm is similar to map lookahead with the exception of saprse sampling of the chip"
2581+
" * compressed_map: The algorithm is similar to map lookahead with the exception of sparse sampling of the chip"
25822582
" to reduce the run-time to build the router lookahead and also its memory footprint\n"
25832583
" * extended_map: A more advanced and extended lookahead which accounts for a more\n"
25842584
" exhaustive node sampling method\n"

vpr/src/route/router_lookahead_compressed_map.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,9 @@ std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNo
428428
auto& device_ctx = g_vpr_ctx.device();
429429
auto& rr_graph = device_ctx.rr_graph;
430430

431-
int delta_x, delta_y;
432431
int from_layer_num = rr_graph.node_layer(from_node);
433432
int to_layer_num = rr_graph.node_layer(to_node);
434-
util::get_xy_deltas(from_node, to_node, &delta_x, &delta_y);
433+
auto [delta_x, delta_y] = util::get_xy_deltas(from_node, to_node);
435434
delta_x = abs(delta_x);
436435
delta_y = abs(delta_y);
437436

vpr/src/route/router_lookahead_map.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ static util::Cost_Entry get_wire_cost_entry(e_rr_type rr_type,
8080
int to_layer_num);
8181

8282
static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segment_inf);
83+
8384
/***
8485
* @brief Compute the cost from pin to sinks of tiles - Compute the minimum cost to get to each tile sink from pins on the cluster
8586
* @param intra_tile_pin_primitive_pin_delay
@@ -253,8 +254,7 @@ float MapLookahead::get_expected_cost_flat_router(RRNodeId current_node, RRNodeI
253254
// Since we don't know which type of wires are accessible from an OPIN inside the cluster, we use
254255
// distance_based_min_cost to get an estimation of the global cost, and then, add this cost to the tile_min_cost
255256
// to have an estimation of the cost of getting into a cluster - We don't have any estimation of the cost to get out of the cluster
256-
int delta_x, delta_y;
257-
util::get_xy_deltas(current_node, target_node, &delta_x, &delta_y);
257+
auto [delta_x, delta_y] = util::get_xy_deltas(current_node, target_node);
258258
delta_x = abs(delta_x);
259259
delta_y = abs(delta_y);
260260
delay_cost = params.criticality * chann_distance_based_min_cost[rr_graph.node_layer(current_node)][to_layer_num][delta_x][delta_y].delay;
@@ -285,8 +285,7 @@ float MapLookahead::get_expected_cost_flat_router(RRNodeId current_node, RRNodeI
285285
delay_offset_cost = 0.;
286286
cong_offset_cost = 0.;
287287
} else {
288-
int delta_x, delta_y;
289-
util::get_xy_deltas(current_node, target_node, &delta_x, &delta_y);
288+
auto [delta_x, delta_y] = util::get_xy_deltas(current_node, target_node);
290289
delta_x = abs(delta_x);
291290
delta_y = abs(delta_y);
292291
delay_cost = params.criticality * chann_distance_based_min_cost[rr_graph.node_layer(current_node)][to_layer_num][delta_x][delta_y].delay;
@@ -309,10 +308,9 @@ std::pair<float, float> MapLookahead::get_expected_delay_and_cong(RRNodeId from_
309308
auto& device_ctx = g_vpr_ctx.device();
310309
auto& rr_graph = device_ctx.rr_graph;
311310

312-
int delta_x, delta_y;
313311
int from_layer_num = rr_graph.node_layer(from_node);
314312
int to_layer_num = rr_graph.node_layer(to_node);
315-
util::get_xy_deltas(from_node, to_node, &delta_x, &delta_y);
313+
auto [delta_x, delta_y] = util::get_xy_deltas(from_node, to_node);
316314
delta_x = abs(delta_x);
317315
delta_y = abs(delta_y);
318316

@@ -513,7 +511,6 @@ static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segm
513511
//Profile each wire segment type
514512
for (int from_layer_num = 0; from_layer_num < grid.get_num_layers(); from_layer_num++) {
515513
for (const auto& segment_inf : segment_inf_vec) {
516-
std::map<t_rr_type, std::vector<RRNodeId>> sample_nodes;
517514
std::vector<e_rr_type> chan_types;
518515
if (segment_inf.parallel_axis == X_AXIS)
519516
chan_types.push_back(CHANX);
@@ -547,10 +544,7 @@ static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segm
547544

548545
/* sets the lookahead cost map entries based on representative cost entries from routing_cost_map */
549546
static void set_lookahead_map_costs(int from_layer_num, int segment_index, e_rr_type chan_type, util::t_routing_cost_map& routing_cost_map) {
550-
int chan_index = 0;
551-
if (chan_type == CHANY) {
552-
chan_index = 1;
553-
}
547+
int chan_index = (chan_type == CHANX) ? 0 : 1;
554548

555549
/* set the lookahead cost map entries with a representative cost entry from routing_cost_map */
556550
for (unsigned to_layer = 0; to_layer < routing_cost_map.dim_size(0); to_layer++) {
@@ -566,10 +560,7 @@ static void set_lookahead_map_costs(int from_layer_num, int segment_index, e_rr_
566560

567561
/* fills in missing lookahead map entries by copying the cost of the closest valid entry */
568562
static void fill_in_missing_lookahead_entries(int segment_index, e_rr_type chan_type) {
569-
int chan_index = 0;
570-
if (chan_type == CHANY) {
571-
chan_index = 1;
572-
}
563+
int chan_index = (chan_type == CHANX) ? 0 : 1;
573564

574565
auto& device_ctx = g_vpr_ctx.device();
575566

@@ -650,7 +641,7 @@ static util::Cost_Entry get_nearby_cost_entry_average_neighbour(int from_layer_n
650641
int to_layer_num,
651642
int segment_index,
652643
int chan_index) {
653-
// Make sure that the given loaction doesn't have a valid entry
644+
// Make sure that the given location doesn't have a valid entry
654645
VTR_ASSERT(std::isnan(f_wire_cost_map[from_layer_num][chan_index][segment_index][to_layer_num][missing_dx][missing_dy].delay));
655646
VTR_ASSERT(std::isnan(f_wire_cost_map[from_layer_num][chan_index][segment_index][to_layer_num][missing_dx][missing_dy].congestion));
656647

0 commit comments

Comments
 (0)