@@ -379,14 +379,10 @@ static int get_delayless_switch_id(const t_det_routing_arch& det_routing_arch,
379379/* *
380380 * @brief Calculates the routing channel width at each grid location.
381381 *
382- * Iterates through all RR nodes and counts how many wires pass through each (x, y) location
382+ * Iterates through all RR nodes and counts how many wires pass through each (layer, x, y) location
383383 * for both horizontal (CHANX) and vertical (CHANY) channels.
384- *
385- * @return A pair of 3D matrices:
386- * - First: CHANX width per [layer][x][y]
387- * - Second: CHANY width per [layer][x][y]
388384 */
389- static std::pair<vtr::NdMatrix< int , 3 >, vtr::NdMatrix< int , 3 >> calculate_channel_width ();
385+ static void alloc_and_init_channel_width ();
390386
391387/* ****************** Subroutine definitions *******************************/
392388
@@ -545,7 +541,7 @@ void create_rr_graph(e_graph_type graph_type,
545541 device_ctx.rr_graph .rr_nodes (),
546542 is_flat);
547543
548- std::tie (mutable_device_ctx. rr_chanx_width , mutable_device_ctx. rr_chany_width ) = calculate_channel_width ();
544+ alloc_and_init_channel_width ();
549545
550546 print_rr_graph_stats ();
551547
@@ -1130,19 +1126,19 @@ static int get_delayless_switch_id(const t_det_routing_arch& det_routing_arch,
11301126 return delayless_switch;
11311127}
11321128
1133- static std::pair<vtr::NdMatrix<int , 3 >, vtr::NdMatrix<int , 3 >> calculate_channel_width () {
1134- const auto & device_ctx = g_vpr_ctx.device ();
1135- const auto & rr_graph = device_ctx.rr_graph ;
1129+ static void alloc_and_init_channel_width () {
1130+ DeviceContext& mutable_device_ctx = g_vpr_ctx.mutable_device ();
1131+ const DeviceGrid& grid = mutable_device_ctx.grid ;
1132+ const auto & rr_graph = mutable_device_ctx.rr_graph ;
1133+
1134+ vtr::NdMatrix<int , 3 >& chanx_width = mutable_device_ctx.rr_chanx_width ;
1135+ vtr::NdMatrix<int , 3 >& chany_width = mutable_device_ctx.rr_chany_width ;
11361136
1137- auto chanx_width = vtr::NdMatrix<int , 3 >({{device_ctx.grid .get_num_layers (),
1138- device_ctx.grid .width (),
1139- device_ctx.grid .height ()}},
1140- 0 );
1137+ chanx_width.resize ({grid.get_num_layers (), grid.width (), grid.height ()});
1138+ chany_width.resize ({grid.get_num_layers (), grid.width (), grid.height ()});
11411139
1142- auto chany_width = vtr::NdMatrix<int , 3 >({{device_ctx.grid .get_num_layers (),
1143- device_ctx.grid .width (),
1144- device_ctx.grid .height ()}},
1145- 0 );
1140+ chanx_width.fill (0 );
1141+ chany_width.fill (0 );
11461142
11471143 for (RRNodeId node_id : rr_graph.nodes ()) {
11481144 e_rr_type rr_type = rr_graph.node_type (node_id);
@@ -1162,7 +1158,19 @@ static std::pair<vtr::NdMatrix<int, 3>, vtr::NdMatrix<int, 3>> calculate_channel
11621158 }
11631159 }
11641160
1165- return {chanx_width, chany_width};
1161+ std::vector<int >& chanx_width_list = mutable_device_ctx.rr_chanx_list ;
1162+ std::vector<int >& chany_width_list = mutable_device_ctx.rr_chany_list ;
1163+
1164+ chanx_width_list.resize (grid.height ());
1165+ chany_width_list.resize (grid.width ());
1166+
1167+ std::ranges::fill (chanx_width_list, 0 );
1168+ std::ranges::fill (chany_width_list, 0 );
1169+
1170+ for (t_physical_tile_loc loc : grid.all_locations ()) {
1171+ chanx_width_list[loc.y ] = std::max (chanx_width[loc.layer_num ][loc.x ][loc.y ], chanx_width_list[loc.y ]);
1172+ chany_width_list[loc.x ] = std::max (chany_width[loc.layer_num ][loc.x ][loc.y ], chany_width_list[loc.x ]);
1173+ }
11661174}
11671175
11681176void build_tile_rr_graph (RRGraphBuilder& rr_graph_builder,
0 commit comments