Skip to content

Commit 1a7fd21

Browse files
committed
rr_graph_util: add get fan-in lists function
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 00a7efd commit 1a7fd21

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

vpr/src/route/rr_graph_util.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
#include <random>
33
#include <algorithm>
44

5+
#include "rr_graph_util.h"
6+
57
#include "vtr_memory.h"
68
#include "vtr_time.h"
79

810
#include "vpr_types.h"
911
#include "vpr_error.h"
1012

1113
#include "globals.h"
12-
#include "rr_graph_util.h"
1314

1415
int seg_index_of_cblock(t_rr_type from_rr_type, int to_node) {
1516
/* Returns the segment number (distance along the channel) of the connection *
@@ -177,3 +178,20 @@ void reorder_rr_graph_nodes(const t_router_opts& router_opts) {
177178
std::get<2>(edge));
178179
});
179180
}
181+
182+
vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list() {
183+
auto& rr_nodes = g_vpr_ctx.device().rr_nodes;
184+
185+
vtr::vector<RRNodeId, std::vector<RREdgeId>> node_fan_in_list;
186+
187+
node_fan_in_list.resize(rr_nodes.size(), std::vector<RREdgeId>(0));
188+
node_fan_in_list.shrink_to_fit();
189+
190+
//Walk the graph and increment fanin on all dwnstream nodes
191+
rr_nodes.for_each_edge(
192+
[&](RREdgeId edge, __attribute__((unused)) RRNodeId src, RRNodeId sink) {
193+
node_fan_in_list[sink].push_back(edge);
194+
});
195+
196+
return node_fan_in_list;
197+
}

vpr/src/route/rr_graph_util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#ifndef RR_GRAPH_UTIL_H
22
#define RR_GRAPH_UTIL_H
33

4+
#include "vpr_types.h"
5+
46
int seg_index_of_cblock(t_rr_type from_rr_type, int to_node);
57

68
int seg_index_of_sblock(int from_node, int to_node);
79

810
void reorder_rr_graph_nodes(const t_router_opts& router_opts);
911

12+
// This function generates and returns a vector indexed by RRNodeId
13+
// containing a list of fan-in edges for each node.
14+
vtr::vector<RRNodeId, std::vector<RREdgeId>> get_fan_in_list();
15+
1016
#endif

0 commit comments

Comments
 (0)