Skip to content

Add a new APIs reserve_nodes() and resize_nodes to RRGraphBuilder #1905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vpr/src/device/rr_graph_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ class RRGraphBuilder {
return node_storage_.count_rr_switches(num_arch_switches, arch_switch_inf, arch_switch_fanins);
}

/** @brief This function reserve storage for RR nodes. */
inline void reserve_nodes(size_t size) {
node_storage_.reserve(size);
}

/** @brief This function resize node storage to accomidate size RR nodes. */
inline void resize_nodes(size_t size) {
node_storage_.resize(size);
}

/** brief Validate that edge data is partitioned correctly
* @note This function is used to validate the correctness of the routing resource graph in terms
* of graph attributes. Strongly recommend to call it when you finish the building a routing resource
Expand Down
4 changes: 2 additions & 2 deletions vpr/src/route/rr_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ static void build_rr_graph(const t_graph_type graph_type,
size_t expected_node_count = num_rr_nodes;
if (clock_modeling == DEDICATED_NETWORK) {
expected_node_count += ClockRRGraphBuilder::estimate_additional_nodes(grid);
device_ctx.rr_nodes.reserve(expected_node_count);
device_ctx.rr_graph_builder.reserve_nodes(expected_node_count);
}
device_ctx.rr_nodes.resize(num_rr_nodes);
device_ctx.rr_graph_builder.resize_nodes(num_rr_nodes);

/* These are data structures used by the the unidir opin mapping. They are used
* to spread connections evenly for each segment type among the available
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/route/rr_graph_uxsdcxx_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ class RrGraphSerializer final : public uxsd::RrGraphBase<RrGraphContextTypes> {
* </xs:complexType>
*/
inline void preallocate_rr_nodes_node(void*& /*ctx*/, size_t size) final {
rr_nodes_->reserve(size);
rr_graph_builder_->reserve_nodes(size);
}
inline int add_rr_nodes_node(void*& /*ctx*/, unsigned int capacity, unsigned int id, uxsd::enum_node_type type) final {
// make_room_in_vector will not allocate if preallocate_rr_nodes_node
Expand Down