Skip to content

Commit 2701610

Browse files
committed
[vpr][route][crr] rebuild rr graph spatial lookup in remove_dangling_chan_nodes
1 parent cd4ee33 commit 2701610

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

vpr/src/route/rr_graph_generation/tileable_rr_graph/tileable_rr_graph_builder.cpp

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030

3131
#include "globals.h"
3232

33-
static void remove_dangling_chan_nodes(RRGraphBuilder& rr_graph_builder);
33+
/**
34+
* @brief Remove dangling chan nodes (chan nodes with no incoming edges) from the rr_graph
35+
* @param grid The device grid
36+
* @param rr_graph_builder The rr_graph builder
37+
*/
38+
static void remove_dangling_chan_nodes(const DeviceGrid& grid,
39+
RRGraphBuilder& rr_graph_builder);
3440

3541
/************************************************************************
3642
* Main function of this file
@@ -282,18 +288,24 @@ void build_tileable_unidir_rr_graph(const std::vector<t_physical_tile_type>& typ
282288
// Allocate and load routing resource switches, which are derived from the switches from the architecture file,
283289
// based on their fanin in the rr graph. This routine also adjusts the rr nodes to point to these new rr switches
284290
device_ctx.rr_graph_builder.init_fan_in();
285-
alloc_and_load_rr_switch_inf(device_ctx.rr_graph_builder, device_ctx.switch_fanin_remap, device_ctx.all_sw_inf, R_minW_nmos, R_minW_pmos, wire_to_arch_ipin_switch, wire_to_rr_ipin_switch);
291+
if (crr_opts.remove_dangling_nodes) {
292+
remove_dangling_chan_nodes(device_ctx.grid,
293+
device_ctx.rr_graph_builder);
294+
}
295+
alloc_and_load_rr_switch_inf(device_ctx.rr_graph_builder,
296+
device_ctx.switch_fanin_remap,
297+
device_ctx.all_sw_inf,
298+
R_minW_nmos,
299+
R_minW_pmos,
300+
wire_to_arch_ipin_switch,
301+
wire_to_rr_ipin_switch);
286302

287303
// Save the channel widths for the newly constructed graph
288304
device_ctx.chan_width = chan_width;
289305

290306
// Save the track ids for tileable routing resource graph
291307
device_ctx.rr_node_track_ids = rr_node_track_ids;
292308

293-
if (crr_opts.remove_dangling_nodes) {
294-
remove_dangling_chan_nodes(device_ctx.rr_graph_builder);
295-
}
296-
297309
// Build incoming edges
298310
device_ctx.rr_graph_builder.partition_edges();
299311
device_ctx.rr_graph_builder.build_in_edges();
@@ -318,8 +330,10 @@ void build_tileable_unidir_rr_graph(const std::vector<t_physical_tile_type>& typ
318330
check_rr_graph(device_ctx.rr_graph, types, device_ctx.rr_indexed_data, grids, vib_grid, device_ctx.chan_width, e_graph_type::UNIDIR_TILEABLE, false);
319331
}
320332

321-
static void remove_dangling_chan_nodes(RRGraphBuilder& rr_graph_builder) {
333+
static void remove_dangling_chan_nodes(const DeviceGrid& grid,
334+
RRGraphBuilder& rr_graph_builder) {
322335
t_rr_graph_storage& rr_nodes = rr_graph_builder.rr_nodes();
336+
RRSpatialLookup& node_lookup = rr_graph_builder.node_lookup();
323337
std::vector<RRNodeId> dangling_nodes;
324338

325339
for (size_t node_index = 0; node_index < rr_nodes.size(); ++node_index) {
@@ -330,21 +344,30 @@ static void remove_dangling_chan_nodes(RRGraphBuilder& rr_graph_builder) {
330344
}
331345
}
332346
}
333-
334-
// Print the info about nodes to be removed in removed_nodes.txt
335-
std::ofstream removed_nodes_file("removed_nodes.txt");
336-
for (const auto& node : dangling_nodes) {
337-
size_t node_index = size_t(node);
338-
auto node_type = rr_nodes.node_type(node);
339-
auto x_low = rr_nodes.node_xlow(node);
340-
auto y_low = rr_nodes.node_ylow(node);
341-
auto x_high = rr_nodes.node_xhigh(node);
342-
auto y_high = rr_nodes.node_yhigh(node);
343-
removed_nodes_file << node_index << " " << rr_node_typename[node_type] << " (" << x_low << "," << y_low << ") to (" << x_high << "," << y_high << ")" << std::endl;
344-
}
345-
removed_nodes_file.close();
346-
347347
rr_nodes.remove_nodes(dangling_nodes);
348348

349+
node_lookup.clear();
350+
// Alloc the lookup table
351+
for (e_rr_type rr_type : RR_TYPES) {
352+
node_lookup.resize_nodes(grid.get_num_layers(),
353+
grid.width(),
354+
grid.height(),
355+
rr_type,
356+
NUM_2D_SIDES);
357+
}
349358

359+
// Add the correct node into the vector
360+
for (size_t node_index = 0; node_index < rr_nodes.size(); ++node_index) {
361+
RRNodeId node = RRNodeId(node_index);
362+
// Set track numbers as a node may have multiple ptc
363+
if (rr_graph_builder.node_contain_multiple_ptc(node)) {
364+
if (rr_nodes.node_type(node) == e_rr_type::CHANX ||
365+
rr_nodes.node_type(node) == e_rr_type::CHANY) {
366+
rr_graph_builder.add_track_node_to_lookup(node);
367+
}
368+
} else {
369+
rr_graph_builder.add_node_to_all_locs(node);
370+
}
371+
}
372+
rr_graph_builder.init_fan_in();
350373
}

0 commit comments

Comments
 (0)