@@ -57,6 +57,7 @@ NocCostHandler::NocCostHandler() {
57
57
proposed_traffic_flow_costs.resize (number_of_traffic_flows, {INVALID_NOC_COST_TERM, INVALID_NOC_COST_TERM});
58
58
59
59
traffic_flow_routes.resize (number_of_traffic_flows, {});
60
+ traffic_flow_routes_backup.resize (number_of_traffic_flows, {});
60
61
61
62
int number_of_noc_links = noc_ctx.noc_model .get_number_of_noc_links ();
62
63
@@ -285,8 +286,7 @@ void NocCostHandler::re_route_associated_traffic_flows(ClusterBlockId moved_bloc
285
286
}
286
287
}
287
288
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) {
290
290
auto & noc_ctx = g_vpr_ctx.noc ();
291
291
const NocTrafficFlows& noc_traffic_flows_storage = noc_ctx.noc_traffic_flows_storage ;
292
292
@@ -309,8 +309,8 @@ void NocCostHandler::revert_noc_traffic_flow_routes(const t_pl_blocks_to_be_move
309
309
for (NocTrafficFlowId traffic_flow_id : assoc_traffic_flows) {
310
310
// first check to see whether we have already reverted the current traffic flow and only revert it if we haven't already.
311
311
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] );
314
314
315
315
// make sure we do not revert this traffic flow again
316
316
reverted_traffic_flows.insert (traffic_flow_id);
@@ -336,6 +336,9 @@ void NocCostHandler::re_route_traffic_flow(NocTrafficFlowId traffic_flow_id,
336
336
const std::vector<NocLinkId>& curr_traffic_flow_route = traffic_flow_routes[traffic_flow_id];
337
337
update_traffic_flow_link_usage (curr_traffic_flow_route, -1 , curr_traffic_flow.traffic_flow_bandwidth );
338
338
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
+
339
342
// now get the re-routed traffic flow route and increment all the link usages with this reverted route
340
343
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);
341
344
update_traffic_flow_link_usage (re_routed_traffic_flow_route, 1 , curr_traffic_flow.traffic_flow_bandwidth );
0 commit comments