Skip to content

Commit 8f7aa26

Browse files
author
Nathan Shreve
committed
Reintroduce dfs recursive fn.; call set_sink_locs after intra-cluster rr graph built
1 parent c16f7df commit 8f7aa26

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

libs/librrgraph/src/base/rr_graph_utils.cpp

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,40 @@
66
#include "rr_graph_obj.h"
77
#include "rr_graph_builder.h"
88

9+
// Add "cluster-edge" IPINs to sink_ipins
10+
static void walk_cluster_recursive(const RRGraphView& rr_graph,
11+
const vtr::vector<RRNodeId, std::vector<RREdgeId>>& fanins,
12+
std::unordered_set<RRNodeId>& sink_ipins,
13+
const RRNodeId curr,
14+
const RRNodeId origin) {
15+
// Make sure SINK in the same cluster as origin
16+
int curr_x = rr_graph.node_xlow(curr);
17+
int curr_y = rr_graph.node_ylow(curr);
18+
if ((curr_x < rr_graph.node_xlow(origin)) || (curr_x > rr_graph.node_xhigh(origin)) || (curr_y < rr_graph.node_ylow(origin)) || (curr_y > rr_graph.node_yhigh(origin)))
19+
return;
20+
21+
VTR_ASSERT_SAFE(rr_graph.node_type(origin) == e_rr_type::SINK);
22+
23+
// We want to go "backward" to the cluster IPINs connected to the origin node
24+
auto incoming_edges = fanins[curr];
25+
for (RREdgeId edge : incoming_edges) {
26+
RRNodeId parent = rr_graph.edge_src_node(edge);
27+
VTR_ASSERT_SAFE(parent != RRNodeId::INVALID());
28+
29+
if (rr_graph.node_type(parent) == e_rr_type::CHANX || rr_graph.node_type(parent) == e_rr_type::CHANY) { /* Outside of origin cluster */
30+
VTR_ASSERT_SAFE(rr_graph.node_type(curr) == e_rr_type::IPIN);
31+
32+
// If the parent node isn't in the origin's cluster, the current node is a "cluster-edge" pin,
33+
// so add it to sink_ipins
34+
sink_ipins.insert(curr);
35+
return;
36+
}
37+
38+
// If the parent node is intra-cluster, keep going "backward"
39+
walk_cluster_recursive(rr_graph, fanins, sink_ipins, parent, origin);
40+
}
41+
}
42+
943
std::vector<RRSwitchId> find_rr_graph_switches(const RRGraph& rr_graph,
1044
const RRNodeId& from_node,
1145
const RRNodeId& to_node) {
@@ -144,22 +178,7 @@ void set_sink_locs(const RRGraphView& rr_graph, RRGraphBuilder& rr_graph_builder
144178

145179
// The IPINs of the current SINK node
146180
std::unordered_set<RRNodeId> sink_ipins = {};
147-
148-
// IPINs are always one node away from the SINK. So, we just get the fanins of the SINK
149-
// and add them to the set
150-
for (auto edge : node_fanins[node_id]) {
151-
RRNodeId pin = rr_graph.edge_src_node(edge);
152-
153-
VTR_ASSERT_SAFE(rr_graph.node_type(pin) == e_rr_type::IPIN);
154-
155-
// Make sure IPIN in the same cluster as origin
156-
size_t curr_x = rr_graph.node_xlow(pin);
157-
size_t curr_y = rr_graph.node_ylow(pin);
158-
if ((curr_x < tile_xlow) || (curr_x > tile_xhigh) || (curr_y < tile_ylow) || (curr_y > tile_yhigh))
159-
continue;
160-
161-
sink_ipins.insert(pin);
162-
}
181+
walk_cluster_recursive(rr_graph, node_fanins, sink_ipins, node_id, node_id);
163182

164183
/* Set SINK locations as average of collected IPINs */
165184

vpr/src/route/rr_graph.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,9 @@ void create_rr_graph(const t_graph_type graph_type,
761761
mutable_device_ctx.rr_graph_is_flat = true;
762762
}
763763

764+
// Get better locations for SINK nodes
765+
set_sink_locs(device_ctx.rr_graph, mutable_device_ctx.rr_graph_builder, grid);
766+
764767
process_non_config_sets();
765768

766769
verify_rr_node_indices(grid,
@@ -1437,9 +1440,6 @@ static void build_rr_graph(const t_graph_type graph_type,
14371440
delete[] clb_to_clb_directs;
14381441
}
14391442

1440-
// Get better locations for SINK nodes
1441-
set_sink_locs(rr_graph, device_ctx.rr_graph_builder, device_ctx.grid);
1442-
14431443
// We are done with building the RR Graph. Thus, we can clear the storages only used
14441444
// to build the RR Graph
14451445
device_ctx.rr_graph_builder.clear_temp_storage();

0 commit comments

Comments
 (0)