Skip to content

Commit 3df3b6b

Browse files
add comments
1 parent 73d96fa commit 3df3b6b

File tree

4 files changed

+68
-26
lines changed

4 files changed

+68
-26
lines changed

vpr/src/base/vpr_api.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,9 @@ void vpr_create_device_grid(const t_vpr_setup& vpr_setup, const t_arch& Arch) {
462462
float target_device_utilization = vpr_setup.PackerOpts.target_device_utilization;
463463
device_ctx.grid = create_device_grid(vpr_setup.device_layout, Arch.grid_layouts, num_type_instances, target_device_utilization);
464464

465-
VTR_ASSERT_MSG(device_ctx.grid.get_num_layers() <= MAX_NUM_LAYERS, "Number of layers should be less than MAX_NUM_LAYERS. If you need more layers, please increase the value of MAX_NUM_LAYERS in vpr_types.h");
465+
VTR_ASSERT_MSG(device_ctx.grid.get_num_layers() <= MAX_NUM_LAYERS,
466+
"Number of layers should be less than MAX_NUM_LAYERS. "
467+
"If you need more layers, please increase the value of MAX_NUM_LAYERS in vpr_types.h");
466468

467469
/*
468470
*Report on the device
@@ -1455,7 +1457,7 @@ void vpr_analysis(const Netlist<>& net_list,
14551457
generate_setup_timing_stats(/*prefix=*/"", *timing_info,
14561458
*analysis_delay_calc, vpr_setup.AnalysisOpts, vpr_setup.RouterOpts.flat_routing);
14571459

1458-
//Write the post-syntesis netlist
1460+
//Write the post-synthesis netlist
14591461
if (vpr_setup.AnalysisOpts.gen_post_synthesis_netlist) {
14601462
netlist_writer(atom_ctx.nlist.netlist_name().c_str(), analysis_delay_calc,
14611463
vpr_setup.AnalysisOpts);

vpr/src/route/router_lookahead_map_utils.cpp

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
#include "route_common.h"
1919
#include "route_debug.h"
2020

21+
/**
22+
* We will profile delay/congestion using this many tracks for each wire type.
23+
* Larger values increase the time to compute the lookahead, but may give
24+
* more accurate lookahead estimates during routing.
25+
*/
26+
static constexpr int MAX_TRACK_OFFSET = 16;
27+
2128
static void dijkstra_flood_to_wires(int itile, RRNodeId inode, util::t_src_opin_delays& src_opin_delays);
2229

2330
static void dijkstra_flood_to_ipins(RRNodeId node, util::t_chan_ipins_delays& chan_ipins_delays);
@@ -51,13 +58,42 @@ static void expand_dijkstra_neighbours(util::PQ_Entry parent_entry,
5158
vtr::vector<RRNodeId, bool>& node_expanded,
5259
std::priority_queue<util::PQ_Entry>& pq);
5360

54-
static std::pair<int, int> adjust_rr_position(const RRNodeId rr);
5561

56-
static std::pair<int, int> adjust_rr_pin_position(const RRNodeId rr);
62+
/**
63+
* @brief Computes the adjusted position of an RR graph node.
64+
* This function does not modify the position of the given node.
65+
* It only returns the computed adjusted position.
66+
* @param rr The ID of the node whose adjusted position is desired.
67+
* @return The adjusted position (x, y).
68+
*/
69+
static std::pair<int, int> get_adjusted_rr_position(RRNodeId rr);
70+
71+
/**
72+
* @brief Computes the adjusted location of a pin to match the position of
73+
* the channel it can reach based on which side of the block it is at.
74+
* @param rr The corresponding node of a pin whose adjusted positions
75+
* is desired.
76+
* @return The adjusted position (x, y).
77+
*/
78+
static std::pair<int, int> get_adjusted_rr_pin_position(RRNodeId rr);
5779

58-
static std::pair<int, int> adjust_rr_wire_position(const RRNodeId rr);
80+
/**
81+
* @brief Computed the adjusted position of a node of type
82+
* CHANX or CHANY. For uni-directional wires, return the position
83+
* of the driver, and for bi-directional wires, compute the middle point.
84+
* @param rr The ID of the node whose adjusted position is desired.
85+
* @return The adjusted position (x, y).
86+
*/
87+
static std::pair<int, int> get_adjusted_rr_wire_position(RRNodeId rr);
5988

60-
static std::pair<int, int> adjust_rr_src_sink_position(const RRNodeId rr);
89+
/**
90+
* @brief Computes the adjusted position and source and sink nodes.
91+
* SOURCE/SINK nodes assume the full dimensions of their associated block/
92+
* This function computes the average position for the given node.
93+
* @param rr SOURCE or SINK node whose adjusted position is needed.
94+
* @return The adjusted position (x, y).
95+
*/
96+
static std::pair<int, int> get_adjusted_rr_src_sink_position(RRNodeId rr);
6197

6298
// Constants needed to reduce the bounding box when expanding CHAN wires to reach the IPINs.
6399
// These are used when finding all the delays to get to the IPINs of all the different tile types
@@ -549,7 +585,6 @@ RRNodeId get_start_node(int layer, int start_x, int start_y, int target_x, int t
549585
return result;
550586
}
551587

552-
/* returns the absolute delta_x and delta_y offset required to reach to_node from from_node */
553588
std::pair<int, int> get_xy_deltas(RRNodeId from_node, RRNodeId to_node) {
554589
auto& device_ctx = g_vpr_ctx.device();
555590
const auto& rr_graph = device_ctx.rr_graph;
@@ -561,8 +596,8 @@ std::pair<int, int> get_xy_deltas(RRNodeId from_node, RRNodeId to_node) {
561596

562597
if (!is_chan(from_type) && !is_chan(to_type)) {
563598
//Alternate formulation for non-channel types
564-
auto [from_x, from_y] = adjust_rr_position(from_node);
565-
auto [to_x, to_y] = adjust_rr_position(to_node);
599+
auto [from_x, from_y] = get_adjusted_rr_position(from_node);
600+
auto [to_x, to_y] = get_adjusted_rr_position(to_node);
566601

567602
delta_x = to_x - from_x;
568603
delta_y = to_y - from_y;
@@ -757,7 +792,7 @@ t_routing_cost_map get_routing_cost_map(int longest_seg_length,
757792
routing_cost_map.fill(Expansion_Cost_Entry());
758793

759794
// to avoid multiple memory allocation and de-allocations in run_dijkstra()
760-
// dijkstra_data is created outside the for loop as passed by reference to dijkstra_data()
795+
// dijkstra_data is created outside the for loop and passed by reference to dijkstra_data()
761796
t_dijkstra_data dijkstra_data;
762797

763798
for (RRNodeId sample_node : sample_nodes) {
@@ -1375,23 +1410,23 @@ static void expand_dijkstra_neighbours(util::PQ_Entry parent_entry,
13751410
}
13761411
}
13771412

1378-
static std::pair<int, int> adjust_rr_position(const RRNodeId rr) {
1413+
static std::pair<int, int> get_adjusted_rr_position(const RRNodeId rr) {
13791414
auto& device_ctx = g_vpr_ctx.device();
13801415
const auto& rr_graph = device_ctx.rr_graph;
13811416

13821417
e_rr_type rr_type = rr_graph.node_type(rr);
13831418

13841419
if (is_chan(rr_type)) {
1385-
return adjust_rr_wire_position(rr);
1420+
return get_adjusted_rr_wire_position(rr);
13861421
} else if (is_pin(rr_type)) {
1387-
return adjust_rr_pin_position(rr);
1422+
return get_adjusted_rr_pin_position(rr);
13881423
} else {
13891424
VTR_ASSERT_SAFE(is_src_sink(rr_type));
1390-
return adjust_rr_src_sink_position(rr);
1425+
return get_adjusted_rr_src_sink_position(rr);
13911426
}
13921427
}
13931428

1394-
static std::pair<int, int> adjust_rr_pin_position(const RRNodeId rr) {
1429+
static std::pair<int, int> get_adjusted_rr_pin_position(const RRNodeId rr) {
13951430
/*
13961431
* VPR uses a co-ordinate system where wires above and to the right of a block
13971432
* are at the same location as the block:
@@ -1458,7 +1493,7 @@ static std::pair<int, int> adjust_rr_pin_position(const RRNodeId rr) {
14581493
return {x, y};
14591494
}
14601495

1461-
static std::pair<int, int> adjust_rr_wire_position(const RRNodeId rr) {
1496+
static std::pair<int, int> get_adjusted_rr_wire_position(const RRNodeId rr) {
14621497
auto& device_ctx = g_vpr_ctx.device();
14631498
const auto& rr_graph = device_ctx.rr_graph;
14641499

@@ -1481,7 +1516,7 @@ static std::pair<int, int> adjust_rr_wire_position(const RRNodeId rr) {
14811516
}
14821517
}
14831518

1484-
static std::pair<int, int> adjust_rr_src_sink_position(const RRNodeId rr) {
1519+
static std::pair<int, int> get_adjusted_rr_src_sink_position(const RRNodeId rr) {
14851520
//SOURCE/SINK nodes assume the full dimensions of their
14861521
//associated block
14871522

vpr/src/route/router_lookahead_map_utils.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
#include "rr_node.h"
2626
#include "rr_graph_view.h"
2727

28-
/* we will profile delay/congestion using this many tracks for each wire type */
29-
static constexpr int MAX_TRACK_OFFSET = 16;
30-
3128
namespace util {
3229

3330
class Cost_Entry;
@@ -330,6 +327,14 @@ t_ipin_primitive_sink_delays compute_intra_tile_dijkstra(const RRGraphView& rr_g
330327
/* returns index of a node from which to start routing */
331328
RRNodeId get_start_node(int layer, int start_x, int start_y, int target_x, int target_y, t_rr_type rr_type, int seg_index, int track_offset);
332329

330+
/**
331+
* @brief Computes the absolute delta_x and delta_y offset
332+
* required to reach to_node from from_node
333+
* @param from_node The starting node
334+
* @param to_node The destination node
335+
* @return (delta_x, delta_y) offset required to reach to
336+
* to_node from from_node.
337+
*/
333338
std::pair<int, int> get_xy_deltas(RRNodeId from_node, RRNodeId to_node);
334339

335340
t_routing_cost_map get_routing_cost_map(int longest_seg_length,

vpr/src/route/rr_graph.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,14 @@ static void add_intra_tile_edges_rr_graph(RRGraphBuilder& rr_graph_builder,
336336
* @brief Add the intra-cluster edges
337337
* @param rr_graph_builder
338338
* @param num_collapsed_nodes Return the number of nodes that are removed due to collapsing
339-
* @param cluster_blk_id Cluser block id of the cluster that its edges are being added
339+
* @param cluster_blk_id Cluster block id of the cluster that its edges are being added
340340
* @param i
341341
* @param j
342342
* @param cap Capacity number of the location that cluster is being mapped to
343343
* @param R_minW_nmos
344344
* @param R_minW_pmos
345345
* @param rr_edges_to_create
346-
* @param nodes_to_collapse Sotre the nodes in the cluster that needs to be collapsed
346+
* @param nodes_to_collapse Store the nodes in the cluster that needs to be collapsed
347347
* @param grid
348348
* @param is_flat
349349
* @param load_rr_graph
@@ -407,7 +407,7 @@ static int add_edges_for_collapsed_nodes(RRGraphBuilder& rr_graph_builder,
407407
int j,
408408
bool load_rr_graph);
409409
/**
410-
* @note This funtion is used to add the fan-in edges of the given chain node to the chain's sink with the modified delay
410+
* @note This function is used to add the fan-in edges of the given chain node to the chain's sink with the modified delay
411411
* @param rr_graph_builder
412412
* @param rr_edges_to_create
413413
* @param num_collapsed_pins
@@ -773,7 +773,7 @@ void create_rr_graph(const t_graph_type graph_type,
773773

774774
// Write out rr graph file if needed - Currently, writing the flat rr-graph is not supported since loading from a flat rr-graph is not supported.
775775
// When this function is called in any stage other than routing, the is_flat flag passed to this function is false, regardless of the flag passed
776-
// through command line. So, the graph conrresponding to global resources will be created and written down to file if needed. During routing, if flat-routing
776+
// through command line. So, the graph corresponding to global resources will be created and written down to file if needed. During routing, if flat-routing
777777
// is enabled, intra-cluster resources will be added to the graph, but this new bigger graph will not be written down.
778778
if (!det_routing_arch->write_rr_graph_filename.empty() && !is_flat) {
779779
write_rr_graph(&mutable_device_ctx.rr_graph_builder,
@@ -4465,7 +4465,7 @@ static std::vector<bool> alloc_and_load_perturb_opins(const t_physical_tile_type
44654465
}
44664466

44674467
n = step_size / prime_factors[i];
4468-
n = n - (float)vtr::nint(n); /* fractinal part */
4468+
n = n - (float)vtr::nint(n); /* fractional part */
44694469
if (fabs(n) < threshold) {
44704470
perturb_opins[0] = true;
44714471
break;
@@ -4512,7 +4512,7 @@ static RRNodeId pick_best_direct_connect_target_rr_node(const RRGraphView& rr_gr
45124512
}
45134513

45144514
//Include a partial unit of distance based on side alignment to ensure
4515-
//we preferr facing sides
4515+
//we prefer facing sides
45164516
if ((from_side == RIGHT && to_side == LEFT)
45174517
|| (from_side == LEFT && to_side == RIGHT)
45184518
|| (from_side == TOP && to_side == BOTTOM)

0 commit comments

Comments
 (0)