@@ -287,6 +287,9 @@ void build_tileable_unidir_rr_graph(const std::vector<t_physical_tile_type>& typ
287287 // Allocate and load routing resource switches, which are derived from the switches from the architecture file,
288288 // based on their fanin in the rr graph. This routine also adjusts the rr nodes to point to these new rr switches
289289 device_ctx.rr_graph_builder .init_fan_in ();
290+ // If requested, remove dangling chan nodes from the rr graph. This is done
291+ // before allocating and loading routing resource switches since removing these nodes
292+ // may affect the fanin of the switches.
290293 if (crr_opts.remove_dangling_nodes ) {
291294 remove_dangling_chan_nodes (device_ctx.grid ,
292295 device_ctx.rr_graph_builder );
@@ -333,6 +336,7 @@ static void remove_dangling_chan_nodes(const DeviceGrid& grid,
333336 RRSpatialLookup& node_lookup = rr_graph_builder.node_lookup ();
334337 std::vector<RRNodeId> dangling_nodes;
335338
339+ // Iterate over chan nodes and find dangling ones
336340 for (size_t node_index = 0 ; node_index < rr_nodes.size (); ++node_index) {
337341 RRNodeId node = RRNodeId (node_index);
338342 if (rr_nodes.node_type (node) == e_rr_type::CHANX || rr_nodes.node_type (node) == e_rr_type::CHANY) {
@@ -342,7 +346,9 @@ static void remove_dangling_chan_nodes(const DeviceGrid& grid,
342346 }
343347 }
344348 rr_nodes.remove_nodes (dangling_nodes);
345-
349+
350+ // After removing dangling chan nodes, we need to update the node lookup
351+ // since some nodes may have been removed, and the node ids have changed
346352 node_lookup.clear ();
347353 // Alloc the lookup table
348354 for (e_rr_type rr_type : RR_TYPES) {
@@ -353,7 +359,7 @@ static void remove_dangling_chan_nodes(const DeviceGrid& grid,
353359 NUM_2D_SIDES);
354360 }
355361
356- // Add the correct node into the vector
362+ // Update other data structures realated to lookup after removing dangling chan nodes
357363 for (size_t node_index = 0 ; node_index < rr_nodes.size (); ++node_index) {
358364 RRNodeId node = RRNodeId (node_index);
359365 // Set track numbers as a node may have multiple ptc
@@ -365,5 +371,8 @@ static void remove_dangling_chan_nodes(const DeviceGrid& grid,
365371 rr_graph_builder.add_node_to_all_locs (node);
366372 }
367373 }
374+
375+ // Initialize the fanin of the rr graph since the fan-in of nodes connected to
376+ // remove nodes is changed
368377 rr_graph_builder.init_fan_in ();
369378}
0 commit comments