Skip to content

Commit 2c7f183

Browse files
fix unit test failure for check_noc_placement_costs()
1 parent 2053c65 commit 2c7f183

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

vpr/src/place/noc_place_utils.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ int NocCostHandler::check_noc_placement_costs(const t_placer_costs& costs,
516516
double error_tolerance,
517517
const t_noc_opts& noc_opts) const {
518518
int error = 0;
519-
NocCostTerms cost_check{0.0, 0.0, 0.0, 0.0};;
519+
NocCostTerms cost_check{0.0, 0.0, 0.0, 0.0};
520520

521521
auto& noc_ctx = g_vpr_ctx.noc();
522522
const NocStorage& noc_model = noc_ctx.noc_model;
@@ -529,9 +529,6 @@ int NocCostHandler::check_noc_placement_costs(const t_placer_costs& costs,
529529
std::unique_ptr<NocRouting> temp_noc_routing_algorithm = NocRoutingAlgorithmCreator::create_routing_algorithm(noc_opts.noc_routing_algorithm,
530530
noc_model);
531531

532-
// stores a temporarily found route for a traffic flow
533-
std::vector<NocLinkId> temp_found_noc_route;
534-
535532
// go through all the traffic flows and find a route for them based on where the routers are placed within the NoC
536533
for (const auto& traffic_flow_id : noc_traffic_flows_storage.get_all_traffic_flow_id()) {
537534
// get the traffic flow with the current id
@@ -545,6 +542,9 @@ int NocCostHandler::check_noc_placement_costs(const t_placer_costs& costs,
545542
NocRouterId source_router_block_id = noc_model.get_router_at_grid_location(block_locs_ref[logical_source_router_block_id].loc);
546543
NocRouterId sink_router_block_id = noc_model.get_router_at_grid_location(block_locs_ref[logical_sink_router_block_id].loc);
547544

545+
// stores a temporarily found route for a traffic flow
546+
std::vector<NocLinkId> temp_found_noc_route;
547+
548548
// route the current traffic flow
549549
temp_noc_routing_algorithm->route_flow(source_router_block_id, sink_router_block_id, traffic_flow_id, temp_found_noc_route, noc_model);
550550

@@ -561,14 +561,13 @@ int NocCostHandler::check_noc_placement_costs(const t_placer_costs& costs,
561561
temp_noc_link_bw_usage[link_id] += curr_traffic_flow.traffic_flow_bandwidth;
562562
VTR_ASSERT(temp_noc_link_bw_usage[link_id] >= 0.0);
563563
}
564-
565-
// clear the current traffic flow route, so we can route the next traffic flow
566-
temp_found_noc_route.clear();
567564
}
568565

569566
// Iterate over all NoC links and accumulate congestion cost
570567
for (const NocLink& link : noc_model.get_noc_links()) {
571-
cost_check.congestion += get_link_congestion_cost(link);
568+
double link_bw = link.get_bandwidth();
569+
double used_link_bw = temp_noc_link_bw_usage[link.get_link_id()];
570+
cost_check.congestion += std::max(used_link_bw - link_bw, 0.) / link_bw;
572571
}
573572

574573
// check whether the aggregate bandwidth placement cost is within the error tolerance

0 commit comments

Comments
 (0)