-
Notifications
You must be signed in to change notification settings - Fork 430
RR Graph - Cut interposer crossing wires #3342
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
base: master
Are you sure you want to change the base?
Changes from 9 commits
998ba66
2546789
21d5080
72e8933
bc9a40a
b6f592a
349d672
e659e23
e9876b3
2d6de4f
16f26ce
ea396cd
4d95419
e2cee0c
4573aa9
6b39edc
0fc6d07
dda2e43
61ebf99
561b5fb
b57b08f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -351,6 +351,17 @@ class RRGraphBuilder { | |
| inline void alloc_and_load_edges(const t_rr_edge_info_set* rr_edges_to_create) { | ||
| node_storage_.alloc_and_load_edges(rr_edges_to_create); | ||
| } | ||
|
|
||
| /** @brief Removes a given list of RREdgeIds for the RR Graph. | ||
| * This method does not preserve the order of edges. If you're | ||
| * calling it after partition_edges has been called, you need | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "you need to call it again" --> you will need to call partition_edges again |
||
| * to call it again. | ||
| * | ||
| * @param rr_edges_to_remove list of RREdgeIds to be removed | ||
| */ | ||
| inline void remove_edges(std::vector<RREdgeId>& rr_edges_to_remove) { | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| node_storage_.remove_edges(rr_edges_to_remove); | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| /** @brief Overrides the associated switch for a given edge by | ||
| * updating the edge to use the passed in switch. */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,8 +2,10 @@ | |
| #include "rr_graph_storage.h" | ||
| #include "physical_types.h" | ||
| #include "rr_graph_fwd.h" | ||
| #include "vtr_assert.h" | ||
| #include "vtr_error.h" | ||
| #include "librrgraph_types.h" | ||
| #include "vtr_util.h" | ||
|
|
||
| #include <algorithm> | ||
| #include <cstddef> | ||
|
|
@@ -57,6 +59,44 @@ void t_rr_graph_storage::alloc_and_load_edges(const t_rr_edge_info_set* rr_edges | |
| } | ||
| } | ||
|
|
||
| void t_rr_graph_storage::remove_edges(std::vector<RREdgeId>& rr_edges_to_remove) { | ||
| size_t starting_edge_count = edge_dest_node_.size(); | ||
|
|
||
| // Sort and make sure all edge indices are unique | ||
| vtr::uniquify(rr_edges_to_remove); | ||
| VTR_ASSERT_SAFE(std::is_sorted(rr_edges_to_remove.begin(), rr_edges_to_remove.end())); | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Index of the last edge | ||
| size_t edge_list_end = edge_dest_node_.size() - 1; | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Iterate backwards through the list of indices we want to remove. | ||
| for (auto it = rr_edges_to_remove.rbegin(); it != rr_edges_to_remove.rend(); ++it) { | ||
AmirhosseinPoolad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| RREdgeId erase_idx = *it; | ||
|
|
||
| // Copy what's at the end of the list to the index we wanted to remove | ||
| edge_dest_node_[erase_idx] = edge_dest_node_[RREdgeId(edge_list_end)]; | ||
| edge_src_node_[erase_idx] = edge_src_node_[RREdgeId(edge_list_end)]; | ||
| edge_switch_[erase_idx] = edge_switch_[RREdgeId(edge_list_end)]; | ||
| edge_remapped_[erase_idx] = edge_remapped_[RREdgeId(edge_list_end)]; | ||
|
|
||
| // At this point we have no copies of what was at erase_idx and two copies of | ||
| // what was at the end of the list. If we make the list one element shorter, | ||
| // we end up with a list that has removed the element at erase_idx. | ||
| edge_list_end--; | ||
|
|
||
| } | ||
|
|
||
| // We have a new index to the end of the list, call erase on the elements past that index | ||
| // to update the std::vector and shrink the actual data structures. | ||
| edge_dest_node_.erase(edge_dest_node_.begin() + edge_list_end + 1, edge_dest_node_.end()); | ||
| edge_src_node_.erase(edge_src_node_.begin() + edge_list_end + 1, edge_src_node_.end()); | ||
| edge_switch_.erase(edge_switch_.begin() + edge_list_end + 1, edge_switch_.end()); | ||
| edge_remapped_.erase(edge_remapped_.begin() + edge_list_end + 1, edge_remapped_.end()); | ||
|
|
||
| VTR_ASSERT(edge_dest_node_.size() == (starting_edge_count - rr_edges_to_remove.size())); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should set partitioned = false here |
||
|
|
||
|
|
||
| void t_rr_graph_storage::assign_first_edges() { | ||
| VTR_ASSERT(node_first_edge_.empty()); | ||
|
|
||
|
|
@@ -68,39 +108,42 @@ void t_rr_graph_storage::assign_first_edges() { | |
| edge_src_node_.end())); | ||
|
|
||
| size_t node_id = 0; | ||
| size_t first_id = 0; | ||
| size_t second_id = 0; | ||
| size_t first_edge_id = 0; | ||
| size_t second_edge_id = 0; | ||
|
|
||
| size_t num_edges = edge_src_node_.size(); | ||
| VTR_ASSERT(edge_dest_node_.size() == num_edges); | ||
| VTR_ASSERT(edge_switch_.size() == num_edges); | ||
| VTR_ASSERT(edge_remapped_.size() == num_edges); | ||
|
|
||
| while (true) { | ||
| VTR_ASSERT(first_id < num_edges); | ||
| VTR_ASSERT(second_id < num_edges); | ||
| size_t current_node_id = size_t(edge_src_node_[RREdgeId(second_id)]); | ||
| VTR_ASSERT(first_edge_id < num_edges); | ||
| VTR_ASSERT(second_edge_id < num_edges); | ||
|
|
||
| size_t current_node_id = size_t(edge_src_node_[RREdgeId(second_edge_id)]); | ||
| if (node_id < current_node_id) { | ||
| // All edges belonging to node_id are assigned. | ||
| while (node_id < current_node_id) { | ||
| // Store any edges belongs to node_id. | ||
| VTR_ASSERT(node_id < node_first_edge_.size()); | ||
| node_first_edge_[RRNodeId(node_id)] = RREdgeId(first_id); | ||
| first_id = second_id; | ||
| node_first_edge_[RRNodeId(node_id)] = RREdgeId(first_edge_id); | ||
| first_edge_id = second_edge_id; | ||
| node_id += 1; | ||
| } | ||
|
|
||
| VTR_ASSERT(node_id == current_node_id); | ||
| node_first_edge_[RRNodeId(node_id)] = RREdgeId(second_id); | ||
| node_first_edge_[RRNodeId(node_id)] = RREdgeId(second_edge_id); | ||
| } else { | ||
| second_id += 1; | ||
| if (second_id == num_edges) { | ||
| second_edge_id += 1; | ||
| if (second_edge_id == num_edges) { | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // All remaining nodes have no edges, set as such. | ||
| for (size_t inode = node_id + 1; inode < node_first_edge_.size(); ++inode) { | ||
| node_first_edge_[RRNodeId(inode)] = RREdgeId(second_id); | ||
| node_first_edge_[RRNodeId(inode)] = RREdgeId(second_edge_id); | ||
| } | ||
|
|
||
| VTR_ASSERT_SAFE(verify_first_edges()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -400,6 +400,14 @@ class t_rr_graph_storage { | |
| return vtr::StrongIdRange<RREdgeId>(first_edge(id), last_edge(id)); | ||
| } | ||
|
|
||
| /** @brief Returns a range of all edges in the RR Graph. | ||
| * This method does not depend on the edges begin correctly | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. begin -> being |
||
| * sorted and can be used before partition_edges is called. | ||
| */ | ||
| inline vtr::StrongIdRange<RREdgeId> all_edges() const { | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return vtr::StrongIdRange<RREdgeId>(RREdgeId(0), RREdgeId(edge_src_node_.size())); | ||
| } | ||
|
|
||
| /** @brief Retrieve the RREdgeId for iedge'th edge in RRNodeId. | ||
| * | ||
| * This method should generally not be used, and instead first_edge and | ||
|
|
@@ -776,6 +784,15 @@ class t_rr_graph_storage { | |
| /** @brief Adds a batch of edges.*/ | ||
| void alloc_and_load_edges(const t_rr_edge_info_set* rr_edges_to_create); | ||
|
|
||
| /** @brief Removes a given list of RREdgeIds for the RR Graph. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'for the RR' -> 'from the RR'
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should say this operation is O(num_edges) in the RR graph, so it should not be called often and edges should be removed in bulk if at all possible. |
||
| * This method does not preserve the order of edges. If you're | ||
| * calling it after partition_edges has been called, you need | ||
| * to call it again. | ||
| * | ||
| * @param rr_edges_to_remove list of RREdgeIds to be removed | ||
| */ | ||
| void remove_edges(std::vector<RREdgeId>& rr_edges_to_remove); | ||
AmirhosseinPoolad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /* Edge finalization methods */ | ||
|
|
||
| /** @brief Counts the number of rr switches needed based on fan in to support mux | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.