Skip to content

Commit 7906b79

Browse files
store a backup of the current route to avoid rerouting when a swap is rejected
1 parent ea103df commit 7906b79

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

vpr/src/place/initial_noc_placement.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void noc_routers_anneal(const t_noc_opts& noc_opts,
288288
}
289289
} else { // The proposed move is rejected
290290
revert_move_blocks(blocks_affected, blk_loc_registry);
291-
noc_cost_handler.revert_noc_traffic_flow_routes(blocks_affected, block_locs);
291+
noc_cost_handler.revert_noc_traffic_flow_routes(blocks_affected);
292292
}
293293
}
294294
}

vpr/src/place/noc_place_utils.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ NocCostHandler::NocCostHandler() {
5757
proposed_traffic_flow_costs.resize(number_of_traffic_flows, {INVALID_NOC_COST_TERM, INVALID_NOC_COST_TERM});
5858

5959
traffic_flow_routes.resize(number_of_traffic_flows, {});
60+
traffic_flow_routes_backup.resize(number_of_traffic_flows, {});
6061

6162
int number_of_noc_links = noc_ctx.noc_model.get_number_of_noc_links();
6263

@@ -285,8 +286,7 @@ void NocCostHandler::re_route_associated_traffic_flows(ClusterBlockId moved_bloc
285286
}
286287
}
287288

288-
void NocCostHandler::revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_moved& blocks_affected,
289-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs) {
289+
void NocCostHandler::revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_moved& blocks_affected) {
290290
auto& noc_ctx = g_vpr_ctx.noc();
291291
const NocTrafficFlows& noc_traffic_flows_storage = noc_ctx.noc_traffic_flows_storage;
292292

@@ -309,8 +309,8 @@ void NocCostHandler::revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_move
309309
for (NocTrafficFlowId traffic_flow_id : assoc_traffic_flows) {
310310
// first check to see whether we have already reverted the current traffic flow and only revert it if we haven't already.
311311
if (reverted_traffic_flows.find(traffic_flow_id) == reverted_traffic_flows.end()) {
312-
// Revert the traffic flow route by re-routing it
313-
re_route_traffic_flow(traffic_flow_id, noc_traffic_flows_storage, noc_ctx.noc_model, *noc_ctx.noc_flows_router, block_locs);
312+
// Revert the traffic flow route by restoring the backup
313+
std::swap(traffic_flow_routes[traffic_flow_id], traffic_flow_routes_backup[traffic_flow_id]);
314314

315315
// make sure we do not revert this traffic flow again
316316
reverted_traffic_flows.insert(traffic_flow_id);
@@ -336,6 +336,9 @@ void NocCostHandler::re_route_traffic_flow(NocTrafficFlowId traffic_flow_id,
336336
const std::vector<NocLinkId>& curr_traffic_flow_route = traffic_flow_routes[traffic_flow_id];
337337
update_traffic_flow_link_usage(curr_traffic_flow_route, -1, curr_traffic_flow.traffic_flow_bandwidth);
338338

339+
// move the current route to a backup container in case it needs to be reverted
340+
std::swap(traffic_flow_routes[traffic_flow_id], traffic_flow_routes_backup[traffic_flow_id]);
341+
339342
// now get the re-routed traffic flow route and increment all the link usages with this reverted route
340343
std::vector<NocLinkId>& re_routed_traffic_flow_route = route_traffic_flow(traffic_flow_id, noc_model, noc_traffic_flows_storage, noc_flows_router, block_locs);
341344
update_traffic_flow_link_usage(re_routed_traffic_flow_route, 1, curr_traffic_flow.traffic_flow_bandwidth);

vpr/src/place/noc_place_utils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ class NocCostHandler {
140140
* the current placement iteration. This includes the cluster ids of
141141
* the moved blocks, their previous locations and their new locations
142142
* after being moved.
143-
* @param block_locs Contains the location where each clustered block is placed at.
144143
*/
145-
void revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_moved& blocks_affected,
146-
const vtr::vector_map<ClusterBlockId, t_block_loc>& block_locs);
144+
void revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_moved& blocks_affected);
147145

148146
/**
149147
* @brief Recompute the NoC costs (aggregate bandwidth and latency) by
@@ -465,6 +463,7 @@ class NocCostHandler {
465463
std::unordered_set<NocLinkId> affected_noc_links;
466464

467465
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> traffic_flow_routes;
466+
vtr::vector<NocTrafficFlowId, std::vector<NocLinkId>> traffic_flow_routes_backup;
468467

469468
///Represents the bandwidth of the data being transmitted on the link. Units in bits-per-second(bps)
470469
vtr::vector<NocLinkId, double> link_bandwidth_usages;

vpr/src/place/place.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ static e_move_result try_swap(const t_annealing_state* state,
15441544
}
15451545
/* Revert the traffic flow routes within the NoC*/
15461546
if (noc_opts.noc) {
1547-
noc_cost_handler->revert_noc_traffic_flow_routes(blocks_affected, block_locs);
1547+
noc_cost_handler->revert_noc_traffic_flow_routes(blocks_affected);
15481548
}
15491549
}
15501550

0 commit comments

Comments
 (0)