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>
5151static 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 */
5656enum 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+ */
7575static 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,
8282static 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+ */
9191static 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+ */
102102static 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+ */
113113static 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+ */
121121static 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+ */
129129static 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_
144144static 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+ */
158158static 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)) */
586586static 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
797797static 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