Skip to content

Commit 25cbc7f

Browse files
author
Nathan Shreve
committed
More comments
1 parent ddf34eb commit 25cbc7f

10 files changed

+134
-84
lines changed

vpr/src/base/vpr_context.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
#ifndef NO_SERVER
3838

3939
#include "gateio.h"
40-
# include "lookahead_profiler.h"
4140
#include "taskresolver.h"
4241

42+
# include "lookahead_profiler.h"
43+
4344
class SetupHoldTimingInfo;
4445
class PostClusterDelayCalculator;
4546

vpr/src/route/connection_router.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,15 @@ void ConnectionRouter<Heap>::add_route_tree_node_to_heap(
924924
tot_cost,
925925
describe_rr_node(device_ctx.rr_graph, device_ctx.grid, device_ctx.rr_indexed_data, inode, is_flat_).c_str());
926926

927-
push_back_node(&heap_, rr_node_route_inf_,
928-
inode, tot_cost, RREdgeId::INVALID(),
929-
backward_path_cost, backward_path_delay, backward_path_congestion, R_upstream);
927+
push_back_node(&heap_,
928+
rr_node_route_inf_,
929+
inode,
930+
tot_cost,
931+
RREdgeId::INVALID(),
932+
backward_path_cost,
933+
backward_path_delay,
934+
backward_path_congestion,
935+
R_upstream);
930936
} else {
931937
float expected_total_cost = compute_node_cost_using_rcv(cost_params, inode, target_node, rt_node.Tdel, 0, R_upstream);
932938

vpr/src/route/connection_router.h

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class ConnectionRouter : public ConnectionRouterInterface {
127127
// Ensure route budgets have been calculated before enabling this
128128
void set_rcv_enabled(bool enable) final;
129129

130+
// Get a const reference to the router's lookahead
130131
const RouterLookahead& get_router_lookahead() const {
131132
return router_lookahead_;
132133
}

vpr/src/route/route_common.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,15 @@ void reserve_locally_used_opins(HeapInterface* heap, float pres_fac, float acc_f
839839

840840
//Add the OPIN to the heap according to it's congestion cost
841841
cost = get_rr_cong_cost(to_node, pres_fac);
842-
add_node_to_heap(heap, route_ctx.rr_node_route_inf,
843-
to_node, cost, RREdgeId::INVALID(),
844-
0., 0., 0., 0.);
842+
add_node_to_heap(heap,
843+
route_ctx.rr_node_route_inf,
844+
to_node,
845+
cost,
846+
RREdgeId::INVALID(),
847+
0.,
848+
0.,
849+
0.,
850+
0.);
845851
}
846852

847853
for (ipin = 0; ipin < num_local_opin; ipin++) {

vpr/src/route/router_delay_profiling.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ bool RouterDelayProfiler::calculate_delay(RRNodeId source_node,
149149
float RouterDelayProfiler::get_min_delay(int physical_tile_type_idx, int from_layer, int to_layer, int dx, int dy) const {
150150
return min_delays_[physical_tile_type_idx][from_layer][to_layer][dx][dy];
151151
}
152+
const Netlist<>& RouterDelayProfiler::get_net_list() const {
153+
return net_list_;
154+
}
152155

153156
//Returns the shortest path delay from src_node to all RR nodes in the RR graph, or NaN if no path exists
154157
vtr::vector<RRNodeId, float> calculate_all_path_delays_from_rr_node(RRNodeId src_rr_node,

vpr/src/route/router_delay_profiling.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ class RouterDelayProfiler {
4343
*/
4444
float get_min_delay(int physical_tile_type_idx, int from_layer, int to_layer, int dx, int dy) const;
4545

46-
const Netlist<>& get_net_list() {
47-
return net_list_;
48-
}
46+
/**
47+
* @brief Get a const reference to the netlist.
48+
*/
49+
const Netlist<>& get_net_list() const;
4950

5051
private:
5152
const Netlist<>& net_list_;

vpr/src/route/router_lookahead.h

+29
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,44 @@ class RouterLookahead {
1515
public:
1616
/**
1717
* @brief Get expected cost from node to target_node.
18+
*
1819
* @attention Either compute or read methods must be invoked before invoking get_expected_cost.
20+
*
1921
* @param node The source node from which the cost to the target node is obtained.
2022
* @param target_node The target node to which the cost is obtained.
2123
* @param params Contain the router parameter such as connection criticality, etc. Used to calculate the cost based on the delay and congestion costs.
2224
* @param R_upstream Upstream resistance to get to the "node".
25+
*
2326
* @return
2427
*/
2528
virtual float get_expected_cost(RRNodeId node, RRNodeId target_node, const t_conn_cost_params& params, float R_upstream) const = 0;
29+
30+
/**
31+
* @brief Get expected (delay, congestion) from node to target_node.
32+
*
33+
* @attention Either compute or read methods must be invoked before invoking get_expected_delay_and_cong.
34+
*
35+
* @param node The source node from which the cost to the target node is obtained.
36+
* @param target_node The target node to which the cost is obtained.
37+
* @param params Contain the router parameter such as connection criticality, etc.
38+
* @param R_upstream Upstream resistance to get to the "node".
39+
*
40+
* @return (delay, congestion)
41+
*
42+
* @warning (delay, congestion) are NOT multiplied by (params.criticality, 1. - params.criticality), respectively.
43+
* scale_delay_and_cong_by_criticality should be called after this function before adding these to calculate the
44+
* expected total cost.
45+
*/
2646
virtual std::pair<float, float> get_expected_delay_and_cong(RRNodeId node, RRNodeId target_node, const t_conn_cost_params& params, float R_upstream) const = 0;
47+
48+
/**
49+
* @brief Multiply delay by params.criticality and cong by (1. - params.criticality). Used in conjunction with
50+
* get_expected_delay_and_cong to calculate the total expected cost.
51+
*
52+
* @param delay
53+
* @param cong
54+
* @param params
55+
*/
2756
void scale_delay_and_cong_by_criticality(float& delay, float& cong, const t_conn_cost_params& params) const;
2857

2958
/**

vpr/src/route/router_lookahead_compressed_map.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ float CompressedMapLookahead::get_expected_cost(RRNodeId current_node, RRNodeId
422422
}
423423
}
424424

425-
std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNodeId from_node, RRNodeId to_node, const t_conn_cost_params& /*params*/, float) const {
425+
std::pair<float, float> CompressedMapLookahead::get_expected_delay_and_cong(RRNodeId from_node,
426+
RRNodeId to_node,
427+
const t_conn_cost_params& /*params*/,
428+
float /*R_upstream*/) const {
426429
auto& device_ctx = g_vpr_ctx.device();
427430
auto& rr_graph = device_ctx.rr_graph;
428431

vpr/src/route/router_lookahead_map.cpp

+72-72
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
/*
2-
* The router lookahead provides an estimate of the cost from an intermediate node to the target node
3-
* during directed (A*-like) routing.
4-
*
5-
* The VPR 7.0 lookahead (route/route_timing.c ==> get_timing_driven_expected_cost) lower-bounds the remaining delay and
6-
* congestion by assuming that a minimum number of wires, of the same type as the current node being expanded, can be used
7-
* to complete the route. While this method is efficient, it can run into trouble with architectures that use
8-
* multiple interconnected wire types.
9-
*
10-
* The lookahead in this file performs undirected Dijkstra searches to evaluate many paths through the routing network,
11-
* starting from all the different wire types in the routing architecture. This ensures the lookahead captures the
12-
* effect of inter-wire connectivity. This information is then reduced into a delta_x delta_y based lookup table for
13-
* reach source wire type (f_cost_map). This is used for estimates from CHANX/CHANY -> SINK nodes. See Section 3.2.4
14-
* in Oleg Petelin's MASc thesis (2016) for more discussion.
15-
*
16-
* To handle estimates starting from SOURCE/OPIN's the lookahead also creates a small side look-up table of the wire types
17-
* which are reachable from each physical tile type's SOURCEs/OPINs (f_src_opin_delays). This is used for
18-
* SRC/OPIN -> CHANX/CHANY estimates.
19-
*
20-
* In the case of SRC/OPIN -> SINK estimates the results from the two look-ups are added together (and the minimum taken
21-
* if there are multiple possibilities).
22-
*/
2+
* The router lookahead provides an estimate of the cost from an intermediate node to the target node
3+
* during directed (A*-like) routing.
4+
*
5+
* The VPR 7.0 lookahead (route/route_timing.c ==> get_timing_driven_expected_cost) lower-bounds the remaining delay and
6+
* congestion by assuming that a minimum number of wires, of the same type as the current node being expanded, can be used
7+
* to complete the route. While this method is efficient, it can run into trouble with architectures that use
8+
* multiple interconnected wire types.
9+
*
10+
* The lookahead in this file performs undirected Dijkstra searches to evaluate many paths through the routing network,
11+
* starting from all the different wire types in the routing architecture. This ensures the lookahead captures the
12+
* effect of inter-wire connectivity. This information is then reduced into a delta_x delta_y based lookup table for
13+
* reach source wire type (f_cost_map). This is used for estimates from CHANX/CHANY -> SINK nodes. See Section 3.2.4
14+
* in Oleg Petelin's MASc thesis (2016) for more discussion.
15+
*
16+
* To handle estimates starting from SOURCE/OPIN's the lookahead also creates a small side look-up table of the wire types
17+
* which are reachable from each physical tile type's SOURCEs/OPINs (f_src_opin_delays). This is used for
18+
* SRC/OPIN -> CHANX/CHANY estimates.
19+
*
20+
* In the case of SRC/OPIN -> SINK estimates the results from the two look-ups are added together (and the minimum taken
21+
* if there are multiple possibilities).
22+
*/
2323

2424
#include <cmath>
2525
#include <vector>
@@ -51,8 +51,8 @@
5151
static constexpr int VALID_NEIGHBOR_NUMBER = 3;
5252

5353
/* when a list of delay/congestion entries at a coordinate in Cost_Entry is boiled down to a single
54-
* representative entry, this enum is passed-in to specify how that representative entry should be
55-
* calculated */
54+
* representative entry, this enum is passed-in to specify how that representative entry should be
55+
* calculated */
5656
enum e_representative_entry_method {
5757
FIRST = 0, //the first cost that was recorded
5858
SMALLEST, //the smallest-delay cost recorded
@@ -69,9 +69,9 @@ t_wire_cost_map f_wire_cost_map;
6969
/******** File-Scope Functions ********/
7070

7171
/***
72-
* @brief Fill f_wire_cost_map. It is a look-up table from CHANX/CHANY (to SINKs) for various distances
73-
* @param segment_inf
74-
*/
72+
* @brief Fill f_wire_cost_map. It is a look-up table from CHANX/CHANY (to SINKs) for various distances
73+
* @param segment_inf
74+
*/
7575
static util::Cost_Entry get_wire_cost_entry(e_rr_type rr_type,
7676
int seg_index,
7777
int from_layer_num,
@@ -82,50 +82,50 @@ static util::Cost_Entry get_wire_cost_entry(e_rr_type rr_type,
8282
static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segment_inf);
8383

8484
/***
85-
* @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
86-
* @param intra_tile_pin_primitive_pin_delay
87-
* @param tile_min_cost
88-
* @param det_routing_arch
89-
* @param device_ctx
90-
*/
85+
* @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
86+
* @param intra_tile_pin_primitive_pin_delay
87+
* @param tile_min_cost
88+
* @param det_routing_arch
89+
* @param device_ctx
90+
*/
9191
static void compute_tiles_lookahead(std::unordered_map<int, util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay,
9292
std::unordered_map<int, std::unordered_map<int, util::Cost_Entry>>& tile_min_cost,
9393
const t_det_routing_arch& det_routing_arch,
9494
const DeviceContext& device_ctx);
9595
/***
96-
* @brief Compute the cose from tile pins to tile sinks
97-
* @param intra_tile_pin_primitive_pin_delay [physical_tile_type_idx][from_pin_ptc_num][sink_ptc_num] -> cost
98-
* @param physical_tile
99-
* @param det_routing_arch
100-
* @param delayless_switch
101-
*/
96+
* @brief Compute the cose from tile pins to tile sinks
97+
* @param intra_tile_pin_primitive_pin_delay [physical_tile_type_idx][from_pin_ptc_num][sink_ptc_num] -> cost
98+
* @param physical_tile
99+
* @param det_routing_arch
100+
* @param delayless_switch
101+
*/
102102
static void compute_tile_lookahead(std::unordered_map<int, util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay,
103103
t_physical_tile_type_ptr physical_tile,
104104
const t_det_routing_arch& det_routing_arch,
105105
const int delayless_switch);
106106

107107
/***
108-
* @brief Compute the minimum cost to get to the sinks from pins on the cluster
109-
* @param tile_min_cost [physical_tile_idx][sink_ptc_num] -> min_cost
110-
* @param physical_tile
111-
* @param intra_tile_pin_primitive_pin_delay [physical_tile_type_idx][from_pin_ptc_num][sink_ptc_num] -> cost
112-
*/
108+
* @brief Compute the minimum cost to get to the sinks from pins on the cluster
109+
* @param tile_min_cost [physical_tile_idx][sink_ptc_num] -> min_cost
110+
* @param physical_tile
111+
* @param intra_tile_pin_primitive_pin_delay [physical_tile_type_idx][from_pin_ptc_num][sink_ptc_num] -> cost
112+
*/
113113
static void store_min_cost_to_sinks(std::unordered_map<int, std::unordered_map<int, util::Cost_Entry>>& tile_min_cost,
114114
t_physical_tile_type_ptr physical_tile,
115115
const std::unordered_map<int, util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay);
116116

117117
/**
118-
* @brief Iterate over the first (channel type) and second (segment type) dimensions of f_wire_cost_map to get the minimum cost for each dx and dy_
119-
* @param internal_opin_global_cost_map This map is populated in this function. [dx][dy] -> cost
120-
*/
118+
* @brief Iterate over the first (channel type) and second (segment type) dimensions of f_wire_cost_map to get the minimum cost for each dx and dy_
119+
* @param internal_opin_global_cost_map This map is populated in this function. [dx][dy] -> cost
120+
*/
121121
static void min_chann_global_cost_map(vtr::NdMatrix<util::Cost_Entry, 4>& distance_min_cost);
122122

123123
/**
124-
* @brief // Given the src/opin map of each physical tile type, iterate over all OPINs/sources of a type and create
125-
* the minimum cost map across all of them for each tile type.
126-
* @param src_opin_delays
127-
* @param distance_min_cost
128-
*/
124+
* @brief // Given the src/opin map of each physical tile type, iterate over all OPINs/sources of a type and create
125+
* the minimum cost map across all of them for each tile type.
126+
* @param src_opin_delays
127+
* @param distance_min_cost
128+
*/
129129
static void min_opin_distance_cost_map(const util::t_src_opin_delays& src_opin_delays, vtr::NdMatrix<util::Cost_Entry, 5>& distance_min_cost);
130130

131131
// Read the file and fill intra_tile_pin_primitive_pin_delay and tile_min_cost
@@ -144,17 +144,17 @@ static void fill_in_missing_lookahead_entries(int segment_index, e_rr_type chan_
144144
static util::Cost_Entry get_nearby_cost_entry(int from_layer_num, int x, int y, int to_layer_num, int segment_index, int chan_index);
145145

146146
/**
147-
* @brief Fill in the missing entry in router lookahead map
148-
* If there is a missing entry in the router lookahead, search among its neighbors in a 3x3 window. If there are `VALID_NEIGHBOR_NUMBER` valid entries,
149-
* take the average of them and fill in the missing entry.
150-
* @param from_layer_num The layer num of the source node
151-
* @param missing_dx Dx of the missing input
152-
* @param missing_dy Dy of the missing input
153-
* @param to_layer_num The layer num of the destination point
154-
* @param segment_index The segment index of the source node
155-
* @param chan_index The channel index of the source node
156-
* @return The cost for the missing entry
157-
*/
147+
* @brief Fill in the missing entry in router lookahead map
148+
* If there is a missing entry in the router lookahead, search among its neighbors in a 3x3 window. If there are `VALID_NEIGHBOR_NUMBER` valid entries,
149+
* take the average of them and fill in the missing entry.
150+
* @param from_layer_num The layer num of the source node
151+
* @param missing_dx Dx of the missing input
152+
* @param missing_dy Dy of the missing input
153+
* @param to_layer_num The layer num of the destination point
154+
* @param segment_index The segment index of the source node
155+
* @param chan_index The channel index of the source node
156+
* @return The cost for the missing entry
157+
*/
158158
static util::Cost_Entry get_nearby_cost_entry_average_neighbour(int from_layer_num,
159159
int missing_dx,
160160
int missing_dy,
@@ -527,11 +527,11 @@ static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segm
527527
}
528528

529529
/* boil down the cost list in routing_cost_map at each coordinate to a representative cost entry and store it in the lookahead
530-
* cost map */
530+
* cost map */
531531
set_lookahead_map_costs(from_layer_num, segment_inf.seg_index, chan_type, routing_cost_map);
532532

533533
/* fill in missing entries in the lookahead cost map by copying the closest cost entries (cost map was computed based on
534-
* a reference coordinate > (0,0) so some entries that represent a cross-chip distance have not been computed) */
534+
* a reference coordinate > (0,0) so some entries that represent a cross-chip distance have not been computed) */
535535
fill_in_missing_lookahead_entries(segment_inf.seg_index, chan_type);
536536
}
537537
}
@@ -585,7 +585,7 @@ static void fill_in_missing_lookahead_entries(int segment_index, e_rr_type chan_
585585
/* returns a cost entry in the f_wire_cost_map that is near the specified coordinates (and preferably towards (0,0)) */
586586
static util::Cost_Entry get_nearby_cost_entry(int from_layer_num, int x, int y, int to_layer_num, int segment_index, int chan_index) {
587587
/* compute the slope from x,y to 0,0 and then move towards 0,0 by one unit to get the coordinates
588-
* of the cost entry to be copied */
588+
* of the cost entry to be copied */
589589

590590
//VTR_ASSERT(x > 0 || y > 0); //Asertion fails in practise. TODO: debug
591591

@@ -796,12 +796,12 @@ static void min_chann_global_cost_map(vtr::NdMatrix<util::Cost_Entry, 4>& distan
796796

797797
static void min_opin_distance_cost_map(const util::t_src_opin_delays& src_opin_delays, vtr::NdMatrix<util::Cost_Entry, 5>& distance_min_cost) {
798798
/**
799-
* This function calculates and stores the minimum cost to reach a point on layer `n_sink`, which is `dx` and `dy` further from the current point
800-
* on layer `n_source` and is located on physical tile type `t`. To compute this cost, the function iterates over all output pins of tile `t`,
801-
* and for each pin, iterates over all segment types accessible by it. It then determines and stores the minimum cost to the destination point.
802-
* "src_opin_delays" stores the routing segments accessible by each OPIN of each physical type on each layer. After getting the accessible segment types,
803-
* "get_wire_cost_entry" is called to get the cost from that segment type to the destination point.
804-
*/
799+
* This function calculates and stores the minimum cost to reach a point on layer `n_sink`, which is `dx` and `dy` further from the current point
800+
* on layer `n_source` and is located on physical tile type `t`. To compute this cost, the function iterates over all output pins of tile `t`,
801+
* and for each pin, iterates over all segment types accessible by it. It then determines and stores the minimum cost to the destination point.
802+
* "src_opin_delays" stores the routing segments accessible by each OPIN of each physical type on each layer. After getting the accessible segment types,
803+
* "get_wire_cost_entry" is called to get the cost from that segment type to the destination point.
804+
*/
805805
int num_tile_types = g_vpr_ctx.device().physical_tile_types.size();
806806
int num_layers = g_vpr_ctx.device().grid.get_num_layers();
807807
int width = (int)g_vpr_ctx.device().grid.width();
@@ -1090,4 +1090,4 @@ void write_router_lookahead(const std::string& file) {
10901090
writeMessageToFile(file, &builder);
10911091
}
10921092

1093-
#endif
1093+
#endif

0 commit comments

Comments
 (0)