Skip to content

Commit 8cea5b3

Browse files
committed
rr_graph_util: add util class
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent 00a7efd commit 8cea5b3

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-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+
void t_rr_graph_util::init_fan_in_list() {
183+
auto& rr_nodes = g_vpr_ctx.device().rr_nodes;
184+
185+
node_fan_in_list_.resize(rr_nodes.size(), std::vector<RREdgeId>(0));
186+
node_fan_in_list_.shrink_to_fit();
187+
188+
//Walk the graph and increment fanin on all dwnstream nodes
189+
rr_nodes.for_each_edge(
190+
[&](RREdgeId edge, __attribute__((unused)) RRNodeId src, RRNodeId sink) {
191+
node_fan_in_list_[sink].push_back(edge);
192+
});
193+
}
194+
195+
t_rr_graph_util::~t_rr_graph_util() {
196+
node_fan_in_list_.clear();
197+
}

vpr/src/route/rr_graph_util.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
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+
// t_rr_graph_util is a utility class that collects utility
13+
// methods that do not strictly belong to the RR graph storage,
14+
// as they can use its public interface.
15+
class t_rr_graph_util {
16+
public:
17+
~t_rr_graph_util();
18+
19+
void init_fan_in_list();
20+
21+
/* Returns a fan-in edge list corresponding to a specific node */
22+
std::vector<RREdgeId> fan_in_list(RRNodeId id) const {
23+
return node_fan_in_list_[id];
24+
}
25+
26+
private:
27+
// Fan in edges for each RR node.
28+
vtr::vector<RRNodeId, std::vector<RREdgeId>> node_fan_in_list_;
29+
};
30+
1031
#endif

0 commit comments

Comments
 (0)