1
1
/*
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
+ */
23
23
24
24
#include < cmath>
25
25
#include < vector>
51
51
static constexpr int VALID_NEIGHBOR_NUMBER = 3 ;
52
52
53
53
/* 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 */
56
56
enum e_representative_entry_method {
57
57
FIRST = 0 , // the first cost that was recorded
58
58
SMALLEST, // the smallest-delay cost recorded
@@ -69,9 +69,9 @@ t_wire_cost_map f_wire_cost_map;
69
69
/* ******* File-Scope Functions ********/
70
70
71
71
/* **
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
+ */
75
75
static util::Cost_Entry get_wire_cost_entry (e_rr_type rr_type,
76
76
int seg_index,
77
77
int from_layer_num,
@@ -82,50 +82,50 @@ static util::Cost_Entry get_wire_cost_entry(e_rr_type rr_type,
82
82
static void compute_router_wire_lookahead (const std::vector<t_segment_inf>& segment_inf);
83
83
84
84
/* **
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
+ */
91
91
static void compute_tiles_lookahead (std::unordered_map<int , util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay,
92
92
std::unordered_map<int , std::unordered_map<int , util::Cost_Entry>>& tile_min_cost,
93
93
const t_det_routing_arch& det_routing_arch,
94
94
const DeviceContext& device_ctx);
95
95
/* **
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
+ */
102
102
static void compute_tile_lookahead (std::unordered_map<int , util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay,
103
103
t_physical_tile_type_ptr physical_tile,
104
104
const t_det_routing_arch& det_routing_arch,
105
105
const int delayless_switch);
106
106
107
107
/* **
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
+ */
113
113
static void store_min_cost_to_sinks (std::unordered_map<int , std::unordered_map<int , util::Cost_Entry>>& tile_min_cost,
114
114
t_physical_tile_type_ptr physical_tile,
115
115
const std::unordered_map<int , util::t_ipin_primitive_sink_delays>& intra_tile_pin_primitive_pin_delay);
116
116
117
117
/* *
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
+ */
121
121
static void min_chann_global_cost_map (vtr::NdMatrix<util::Cost_Entry, 4 >& distance_min_cost);
122
122
123
123
/* *
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
+ */
129
129
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);
130
130
131
131
// 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_
144
144
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);
145
145
146
146
/* *
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
+ */
158
158
static util::Cost_Entry get_nearby_cost_entry_average_neighbour (int from_layer_num,
159
159
int missing_dx,
160
160
int missing_dy,
@@ -527,11 +527,11 @@ static void compute_router_wire_lookahead(const std::vector<t_segment_inf>& segm
527
527
}
528
528
529
529
/* 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 */
531
531
set_lookahead_map_costs (from_layer_num, segment_inf.seg_index , chan_type, routing_cost_map);
532
532
533
533
/* 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) */
535
535
fill_in_missing_lookahead_entries (segment_inf.seg_index , chan_type);
536
536
}
537
537
}
@@ -585,7 +585,7 @@ static void fill_in_missing_lookahead_entries(int segment_index, e_rr_type chan_
585
585
/* returns a cost entry in the f_wire_cost_map that is near the specified coordinates (and preferably towards (0,0)) */
586
586
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) {
587
587
/* 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 */
589
589
590
590
// VTR_ASSERT(x > 0 || y > 0); //Asertion fails in practise. TODO: debug
591
591
@@ -796,12 +796,12 @@ static void min_chann_global_cost_map(vtr::NdMatrix<util::Cost_Entry, 4>& distan
796
796
797
797
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) {
798
798
/* *
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
+ */
805
805
int num_tile_types = g_vpr_ctx.device ().physical_tile_types .size ();
806
806
int num_layers = g_vpr_ctx.device ().grid .get_num_layers ();
807
807
int width = (int )g_vpr_ctx.device ().grid .width ();
@@ -1090,4 +1090,4 @@ void write_router_lookahead(const std::string& file) {
1090
1090
writeMessageToFile (file, &builder);
1091
1091
}
1092
1092
1093
- #endif
1093
+ #endif
0 commit comments