Skip to content

Commit 3111500

Browse files
committed
lookahead: fixed rebase conflicts
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent fb214f2 commit 3111500

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

vpr/src/route/router_lookahead_extended_map.cpp

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static std::pair<float, int> run_dijkstra(RRNodeId start_node,
6464
std::vector<util::Search_Path>* paths,
6565
util::RoutingCosts* routing_costs);
6666

67-
float ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, float criticality_fac) const {
67+
std::pair<float, float> ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, const t_conn_cost_params& params) const {
6868
auto& device_ctx = g_vpr_ctx.device();
6969
auto& rr_graph = device_ctx.rr_nodes;
7070

@@ -96,12 +96,14 @@ float ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, i
9696
//The cost estimate should still be *extremely* large compared to a typical delay, and
9797
//so should ensure that the router de-prioritizes exploring this path, but does not
9898
//forbid the router from trying.
99-
return std::numeric_limits<float>::max() / 1e12;
99+
float max = std::numeric_limits<float>::max() / 1e12;
100+
return std::make_pair(max, max);
100101
} else {
101102
//From the current SOURCE/OPIN we look-up the wiretypes which are reachable
102103
//and then add the estimates from those wire types for the distance of interest.
103104
//If there are multiple options we use the minimum value.
104-
float expected_cost = std::numeric_limits<float>::infinity();
105+
float expected_delay_cost = std::numeric_limits<float>::infinity();
106+
float expected_cong_cost = std::numeric_limits<float>::infinity();
105107

106108
for (const auto& kv : this->src_opin_delays[tile_index][from_ptc]) {
107109
const util::t_reachable_wire_inf& reachable_wire_inf = kv.second;
@@ -119,14 +121,15 @@ float ExtendedMapLookahead::get_src_opin_cost(RRNodeId from_node, int delta_x, i
119121
cost_entry = cost_map_.find_cost(reachable_wire_inf.wire_seg_index, delta_x, delta_y);
120122
}
121123

122-
float this_cost = (criticality_fac) * (reachable_wire_inf.congestion + cost_entry.congestion)
123-
+ (1. - criticality_fac) * (reachable_wire_inf.delay + cost_entry.delay);
124+
float this_delay_cost = (1. - params.criticality) * (reachable_wire_inf.delay + cost_entry.delay);
125+
float this_cong_cost = (params.criticality) * (reachable_wire_inf.congestion + cost_entry.congestion);
124126

125-
expected_cost = std::min(this_cost, expected_cost);
127+
expected_delay_cost = std::min(expected_delay_cost, this_delay_cost);
128+
expected_cong_cost = std::min(expected_cong_cost, this_cong_cost);
126129
}
127130

128-
VTR_ASSERT(std::isfinite(expected_cost));
129-
return expected_cost;
131+
VTR_ASSERT(std::isfinite(expected_delay_cost) && std::isfinite(expected_cong_cost));
132+
return std::make_pair(expected_delay_cost, expected_cong_cost);
130133
}
131134

132135
VTR_ASSERT_SAFE_MSG(false,
@@ -163,13 +166,14 @@ float ExtendedMapLookahead::get_chan_ipin_delays(RRNodeId to_node) const {
163166
//
164167
// The from_node can be of one of the following types: CHANX, CHANY, SOURCE, OPIN
165168
// The to_node is always a SINK
166-
float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
167-
RRNodeId to_node,
168-
float criticality_fac) const {
169-
if (from_node == to_node) {
170-
return 0.f;
169+
std::pair<float, float> ExtendedMapLookahead::get_expected_delay_and_cong(int inode, int target_node, const t_conn_cost_params& params, float /*R_upstream*/) const {
170+
if (inode == target_node) {
171+
return std::make_pair(0., 0.);
171172
}
172173

174+
RRNodeId from_node(inode);
175+
RRNodeId to_node(target_node);
176+
173177
auto& device_ctx = g_vpr_ctx.device();
174178
auto& rr_graph = device_ctx.rr_nodes;
175179

@@ -185,7 +189,9 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
185189

186190
e_rr_type from_type = rr_graph.node_type(from_node);
187191
if (from_type == SOURCE || from_type == OPIN) {
188-
return this->get_src_opin_cost(from_node, dx, dy, criticality_fac);
192+
return this->get_src_opin_cost(from_node, dx, dy, params);
193+
} else if (from_type == IPIN) {
194+
return std::make_pair(0., 0.);
189195
}
190196

191197
int from_seg_index = cost_map_.node_to_segment(size_t(from_node));
@@ -197,7 +203,8 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
197203
"Not connected %d (%s, %d) -> %d (%s)\n",
198204
size_t(from_node), device_ctx.rr_nodes[size_t(from_node)].type_string(), from_seg_index,
199205
size_t(to_node), device_ctx.rr_nodes[size_t(to_node)].type_string());
200-
return std::numeric_limits<float>::infinity();
206+
float infinity = std::numeric_limits<float>::infinity();
207+
return std::make_pair(infinity, infinity);
201208
}
202209

203210
float expected_delay = cost_entry.delay;
@@ -216,16 +223,19 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
216223
float site_pin_delay = this->get_chan_ipin_delays(to_node);
217224
expected_delay += site_pin_delay;
218225

219-
float expected_cost = criticality_fac * expected_delay + (1.0 - criticality_fac) * expected_congestion;
226+
float expected_delay_cost = params.criticality * expected_delay;
227+
float expected_cong_cost = (1.0 - params.criticality) * expected_congestion;
228+
229+
float expected_cost = expected_delay_cost + expected_cong_cost;
220230

221231
VTR_LOGV_DEBUG(f_router_debug, "Requested lookahead from node %d to %d\n", size_t(from_node), size_t(to_node));
222232
const std::string& segment_name = device_ctx.rr_segments[from_seg_index].name;
223233
VTR_LOGV_DEBUG(f_router_debug, "Lookahead returned %s (%d) with distance (%zd, %zd)\n",
224234
segment_name.c_str(), from_seg_index,
225235
dx, dy);
226-
VTR_LOGV_DEBUG(f_router_debug, "Lookahead delay: %g\n", expected_delay);
227-
VTR_LOGV_DEBUG(f_router_debug, "Lookahead congestion: %g\n", expected_congestion);
228-
VTR_LOGV_DEBUG(f_router_debug, "Criticality: %g\n", criticality_fac);
236+
VTR_LOGV_DEBUG(f_router_debug, "Lookahead delay: %g\n", expected_delay_cost);
237+
VTR_LOGV_DEBUG(f_router_debug, "Lookahead congestion: %g\n", expected_cong_cost);
238+
VTR_LOGV_DEBUG(f_router_debug, "Criticality: %g\n", params.criticality);
229239
VTR_LOGV_DEBUG(f_router_debug, "Lookahead cost: %g\n", expected_cost);
230240
VTR_LOGV_DEBUG(f_router_debug, "Site pin delay: %g\n", site_pin_delay);
231241

@@ -239,7 +249,7 @@ float ExtendedMapLookahead::get_map_cost(RRNodeId from_node,
239249
VTR_ASSERT(0);
240250
}
241251

242-
return expected_cost;
252+
return std::make_pair(expected_delay_cost, expected_cong_cost);
243253
}
244254

245255
// Adds a best cost routing path from start_node_ind to node_ind to routing costs
@@ -560,20 +570,23 @@ float ExtendedMapLookahead::get_expected_cost(
560570
int current_node,
561571
int target_node,
562572
const t_conn_cost_params& params,
563-
float /*R_upstream*/) const {
573+
float R_upstream) const {
564574
auto& device_ctx = g_vpr_ctx.device();
565575

566576
t_rr_type rr_type = device_ctx.rr_nodes[current_node].type();
567577

568578
if (rr_type == CHANX || rr_type == CHANY || rr_type == SOURCE || rr_type == OPIN) {
569-
return get_map_cost(
570-
RRNodeId(current_node), RRNodeId(target_node), params.criticality);
579+
float delay_cost, cong_cost;
580+
581+
// Get the total cost using the combined delay and congestion costs
582+
std::tie(delay_cost, cong_cost) = get_expected_delay_and_cong(current_node, target_node, params, R_upstream);
583+
return delay_cost + cong_cost;
571584
} else if (rr_type == IPIN) { /* Change if you're allowing route-throughs */
572585
// This is to return only the cost between the IPIN and SINK. No need to
573586
// query the cost map, as the routing of this connection is almost done.
574-
return (device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost);
587+
return device_ctx.rr_indexed_data[SINK_COST_INDEX].base_cost;
575588
} else { /* Change this if you want to investigate route-throughs */
576-
return (0.);
589+
return 0.;
577590
}
578591
}
579592

vpr/src/route/router_lookahead_extended_map.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ExtendedMapLookahead : public RouterLookahead {
2525
* @param criticality_fac criticality of the current connection between 0 (all congestion) and 1 (all timing)
2626
* @return expected cost to get to the destination
2727
*/
28-
float get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, float criticality_fac) const;
28+
std::pair<float, float> get_src_opin_cost(RRNodeId from_node, int delta_x, int delta_y, const t_conn_cost_params& params) const;
2929

3030
/**
3131
* @brief Returns the CHAN -> IPIN delay that gets added to the final expected delay
@@ -54,15 +54,18 @@ class ExtendedMapLookahead : public RouterLookahead {
5454
std::vector<util::Search_Path>* paths,
5555
util::RoutingCosts* routing_costs);
5656

57-
float get_map_cost(RRNodeId from_node, RRNodeId to_node, float criticality_fac) const;
58-
5957
CostMap cost_map_; ///<Cost map containing all data to extract the entry cost when querying the lookahead.
6058
public:
6159
/**
6260
* @brief Returns the expected cost to get to a destination node
6361
*/
6462
float get_expected_cost(int node, int target_node, const t_conn_cost_params& params, float R_upstream) const override;
6563

64+
/**
65+
* @brief Returns a pair of expected delay and congestion
66+
*/
67+
std::pair<float, float> get_expected_delay_and_cong(int inode, int target_node, const t_conn_cost_params& params, float R_upstream) const override;
68+
6669
/**
6770
* @brief Computes the extended lookahead map
6871
*/

vpr/src/route/router_lookahead_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ float MapLookahead::get_expected_cost(int current_node, int target_node, const t
234234
auto& device_ctx = g_vpr_ctx.device();
235235
auto& rr_graph = device_ctx.rr_nodes;
236236

237-
t_rr_type rr_type = rr_graph.node_type(current);
237+
t_rr_type rr_type = rr_graph.node_type(RRNodeId(current_node));
238238

239239
if (rr_type == CHANX || rr_type == CHANY || rr_type == SOURCE || rr_type == OPIN) {
240240
float delay_cost, cong_cost;

0 commit comments

Comments
 (0)