99#include " physical_types_util.h"
1010#include " route_export.h"
1111#include " vpr_utils.h"
12+ #include " route_utilization.h"
1213
1314#if defined(VPR_USE_TBB)
1415#include < tbb/parallel_for_each.h>
@@ -79,10 +80,15 @@ static bool classes_in_same_block(ParentBlockId blk_id, int first_class_ptc_num,
7980 * @param route_opts Contains channel utilization threshold and weighting factor
8081 * used to increase initial 'acc_cost' for nodes going through
8182 * congested channels.
83+ * @param chanx_util Post-placement estimate of CHANX routing utilization per (layer, x, y) location.
84+ * @param chany_util Post-placement estimate of CHANY routing utilization per (layer, x, y) location.
8285 * @return Initial `acc_cost` for the given RR node.
8386 */
87+
8488static float comp_initial_acc_cost (RRNodeId node_id,
85- const t_router_opts& route_opts);
89+ const t_router_opts& route_opts,
90+ const vtr::NdMatrix<double , 3 >& chanx_util,
91+ const vtr::NdMatrix<double , 3 >& chany_util);
8692
8793/* ************************* Subroutine definitions ***************************/
8894
@@ -430,7 +436,9 @@ void alloc_and_load_rr_node_route_structs(const t_router_opts& router_opts) {
430436}
431437
432438static float comp_initial_acc_cost (RRNodeId node_id,
433- const t_router_opts& route_opts) {
439+ const t_router_opts& route_opts,
440+ const vtr::NdMatrix<double , 3 >& chanx_util,
441+ const vtr::NdMatrix<double , 3 >& chany_util) {
434442 const auto & route_ctx = g_vpr_ctx.routing ();
435443 const auto & rr_graph = g_vpr_ctx.device ().rr_graph ;
436444
@@ -444,23 +452,22 @@ static float comp_initial_acc_cost(RRNodeId node_id,
444452 const double weight = route_opts.initial_acc_cost_chan_congestion_weight ;
445453
446454 // TODO: We don't have an explicit CHANZ type. These wires are marked as CHANX. This should be fixed.
447- if (is_chan (rr_type) && !route_ctx.chanx_util .empty ()) {
448- VTR_ASSERT_SAFE (!route_ctx.chany_util .empty ());
455+ if (is_chan (rr_type)) {
449456 double max_util = 0 .;
450457
451458 if (rr_type == e_rr_type::CHANX) {
452459 int y = rr_graph.node_ylow (node_id);
453460 int layer = rr_graph.node_layer (node_id);
454461 for (int x = rr_graph.node_xlow (node_id); x <= rr_graph.node_xhigh (node_id); x++) {
455- max_util = std::max (max_util, route_ctx. chanx_util [layer][x][y]);
462+ max_util = std::max (max_util, chanx_util[layer][x][y]);
456463 }
457464
458465 } else {
459466 VTR_ASSERT_SAFE (rr_type == e_rr_type::CHANY);
460467 int x = rr_graph.node_xlow (node_id);
461468 int layer = rr_graph.node_layer (node_id);
462469 for (int y = rr_graph.node_ylow (node_id); y <= rr_graph.node_yhigh (node_id); y++) {
463- max_util = std::max (max_util, route_ctx. chany_util [layer][x][y]);
470+ max_util = std::max (max_util, chany_util[layer][x][y]);
464471 }
465472 }
466473
@@ -475,14 +482,19 @@ void reset_rr_node_route_structs(const t_router_opts& route_opts) {
475482
476483 auto & route_ctx = g_vpr_ctx.mutable_routing ();
477484 const auto & device_ctx = g_vpr_ctx.device ();
485+ const auto & blk_loc_registry = g_vpr_ctx.placement ().blk_loc_registry ();
486+ const bool cube_bb = g_vpr_ctx.placement ().cube_bb ;
478487
479488 VTR_ASSERT (route_ctx.rr_node_route_inf .size () == size_t (device_ctx.rr_graph .num_nodes ()));
480489
490+ RoutingChanUtilEstimator routing_chan_util_estimator (blk_loc_registry, cube_bb);
491+ const auto [chanx_util, chany_util] = routing_chan_util_estimator.estimate_routing_chan_util ();
492+
481493 for (const RRNodeId rr_id : device_ctx.rr_graph .nodes ()) {
482494 t_rr_node_route_inf& node_inf = route_ctx.rr_node_route_inf [rr_id];
483495
484496 node_inf.prev_edge = RREdgeId::INVALID ();
485- node_inf.acc_cost = comp_initial_acc_cost (rr_id, route_opts);
497+ node_inf.acc_cost = comp_initial_acc_cost (rr_id, route_opts, chanx_util, chany_util );
486498 node_inf.path_cost = std::numeric_limits<float >::infinity ();
487499 node_inf.backward_path_cost = std::numeric_limits<float >::infinity ();
488500 node_inf.set_occ (0 );
0 commit comments