Skip to content

Commit 1fc8b8a

Browse files
author
Muhammad Haris Zafar
authored
Merge branch 'master' into api_make_edges_switch_ids
2 parents 3a59e0f + bbaefca commit 1fc8b8a

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

vpr/src/device/rr_graph_builder.h

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ class RRGraphBuilder {
103103
node_storage_.set_node_direction(id, new_direction);
104104
}
105105

106+
/** @brief Reserve the lists of edges to be memory efficient.
107+
* This function is mainly used to reserve memory space inside RRGraph,
108+
* when adding a large number of edges in order to avoid memory fragements */
109+
inline void reserve_edges(size_t num_edges) {
110+
node_storage_.reserve_edges(num_edges);
111+
}
112+
113+
/** @brief emplace_back_edge; It add one edge. This method is efficient if reserve_edges was called with
114+
* the number of edges present in the graph. */
115+
inline void emplace_back_edge(RRNodeId src, RRNodeId dest, short edge_switch) {
116+
node_storage_.emplace_back_edge(src, dest, edge_switch);
117+
}
118+
119+
/** @brief alloc_and_load_edges; It adds a batch of edges. */
120+
inline void alloc_and_load_edges(const t_rr_edge_info_set* rr_edges_to_create) {
121+
node_storage_.alloc_and_load_edges(rr_edges_to_create);
122+
}
123+
106124
/** @brief set_node_cost_index gets the index of cost data in the list of cost_indexed_data data structure
107125
* It contains the routing cost for different nodes in the RRGraph
108126
* when used in evaluate different routing paths
@@ -127,6 +145,11 @@ class RRGraphBuilder {
127145
node_storage_.remap_rr_node_switch_indices(switch_fanin);
128146
}
129147

148+
/** @brief Marks that edge switch values are rr switch indicies*/
149+
inline void mark_edges_as_rr_switch_ids() {
150+
node_storage_.mark_edges_as_rr_switch_ids();
151+
}
152+
130153
/** @brief Counts the number of rr switches needed based on fan in to support mux
131154
* size dependent switch delays. */
132155
inline size_t count_rr_switches(
@@ -136,9 +159,13 @@ class RRGraphBuilder {
136159
return node_storage_.count_rr_switches(num_arch_switches, arch_switch_inf, arch_switch_fanins);
137160
}
138161

139-
/** @brief Marks that edge switch values are rr switch indicies*/
140-
inline void mark_edges_as_rr_switch_ids() {
141-
node_storage_.mark_edges_as_rr_switch_ids();
162+
/** brief Validate that edge data is partitioned correctly
163+
* @note This function is used to validate the correctness of the routing resource graph in terms
164+
* of graph attributes. Strongly recommend to call it when you finish the building a routing resource
165+
* graph. If you need more advance checks, which are related to architecture features, you should
166+
* consider to use the check_rr_graph() function or build your own check_rr_graph() function. */
167+
inline bool validate() const {
168+
return node_storage_.validate();
142169
}
143170

144171
/** @brief Init per node fan-in data. Should only be called after all edges have

vpr/src/route/rr_graph.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void build_rr_chan(RRGraphBuilder& rr_graph_builder,
236236

237237
void uniquify_edges(t_rr_edge_info_set& rr_edges_to_create);
238238

239-
void alloc_and_load_edges(t_rr_graph_storage& L_rr_node,
239+
void alloc_and_load_edges(RRGraphBuilder& rr_graph_builder,
240240
const t_rr_edge_info_set& rr_edges_to_create);
241241

242242
static void alloc_and_load_rr_switch_inf(const int num_arch_switches,
@@ -1178,7 +1178,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
11781178

11791179
//Create the actual SOURCE->OPIN, IPIN->SINK edges
11801180
uniquify_edges(rr_edges_to_create);
1181-
alloc_and_load_edges(L_rr_node, rr_edges_to_create);
1181+
alloc_and_load_edges(rr_graph_builder, rr_edges_to_create);
11821182
rr_edges_to_create.clear();
11831183
}
11841184
}
@@ -1206,7 +1206,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12061206

12071207
//Create the actual OPIN->CHANX/CHANY edges
12081208
uniquify_edges(rr_edges_to_create);
1209-
alloc_and_load_edges(L_rr_node, rr_edges_to_create);
1209+
alloc_and_load_edges(rr_graph_builder, rr_edges_to_create);
12101210
rr_edges_to_create.clear();
12111211
}
12121212
}
@@ -1228,7 +1228,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12281228

12291229
//Create the actual CHAN->CHAN edges
12301230
uniquify_edges(rr_edges_to_create);
1231-
alloc_and_load_edges(L_rr_node, rr_edges_to_create);
1231+
alloc_and_load_edges(rr_graph_builder, rr_edges_to_create);
12321232
rr_edges_to_create.clear();
12331233
}
12341234
if (j > 0) {
@@ -1243,7 +1243,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12431243

12441244
//Create the actual CHAN->CHAN edges
12451245
uniquify_edges(rr_edges_to_create);
1246-
alloc_and_load_edges(L_rr_node, rr_edges_to_create);
1246+
alloc_and_load_edges(rr_graph_builder, rr_edges_to_create);
12471247
rr_edges_to_create.clear();
12481248
}
12491249
}
@@ -1255,7 +1255,7 @@ static std::function<void(t_chan_width*)> alloc_and_load_rr_graph(RRGraphBuilder
12551255
ClockRRGraphBuilder builder(chan_width, grid, &L_rr_node, &rr_graph_builder);
12561256
builder.create_and_append_clock_rr_graph(num_seg_types, &rr_edges_to_create);
12571257
uniquify_edges(rr_edges_to_create);
1258-
alloc_and_load_edges(L_rr_node, rr_edges_to_create);
1258+
alloc_and_load_edges(rr_graph_builder, rr_edges_to_create);
12591259
rr_edges_to_create.clear();
12601260
update_chan_width = [builder](t_chan_width* c) {
12611261
builder.update_chan_width(c);
@@ -1685,9 +1685,8 @@ void uniquify_edges(t_rr_edge_info_set& rr_edges_to_create) {
16851685
rr_edges_to_create.erase(std::unique(rr_edges_to_create.begin(), rr_edges_to_create.end()), rr_edges_to_create.end());
16861686
}
16871687

1688-
void alloc_and_load_edges(t_rr_graph_storage& L_rr_node,
1689-
const t_rr_edge_info_set& rr_edges_to_create) {
1690-
L_rr_node.alloc_and_load_edges(&rr_edges_to_create);
1688+
void alloc_and_load_edges(RRGraphBuilder& rr_graph_builder, const t_rr_edge_info_set& rr_edges_to_create) {
1689+
rr_graph_builder.alloc_and_load_edges(&rr_edges_to_create);
16911690
}
16921691

16931692
/* allocate pin to track map for each segment type individually and then combine into a single

vpr/src/route/rr_graph_uxsdcxx_serializer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
872872
* </xs:complexType>
873873
*/
874874
inline void preallocate_rr_edges_edge(void*& /*ctx*/, size_t size) final {
875-
rr_nodes_->reserve_edges(size);
875+
rr_graph_builder_->reserve_edges(size);
876876
if (read_edge_metadata_) {
877877
rr_edge_metadata_->reserve(size);
878878
}
@@ -891,7 +891,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
891891
bind.set_ignore();
892892
}
893893

894-
rr_nodes_->emplace_back_edge(RRNodeId(src_node), RRNodeId(sink_node), switch_id);
894+
rr_graph_builder_->emplace_back_edge(RRNodeId(src_node), RRNodeId(sink_node), switch_id);
895895
return bind;
896896
}
897897
inline void finish_rr_edges_edge(MetadataBind& bind) final {

0 commit comments

Comments
 (0)