-
Notifications
You must be signed in to change notification settings - Fork 416
API reorder_rr_graph_node() created in rr_graph_util.cpp #1939
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
API reorder_rr_graph_node() created in rr_graph_util.cpp #1939
Conversation
@tangxifan |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Raza-jafari-RS Let me know if you are fine with the comments. Feel free to ask questions.
vpr/src/device/rr_graph_builder.cpp
Outdated
@@ -1,5 +1,8 @@ | |||
#include "vtr_log.h" | |||
#include "rr_graph_builder.h" | |||
#include "vtr_time.h" | |||
#include <queue> | |||
#include "globals.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No globals in the rr_graph_builder. The data structure should be self-contained.
vpr/src/device/rr_graph_builder.cpp
Outdated
|
||
void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { | ||
auto& device_ctx = g_vpr_ctx.mutable_device(); | ||
auto& rr_graph = device_ctx.rr_graph; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now node_storage_
is already an internal data of the RRGraphBuilder
. You do not need to call global variables anymore.
vpr/src/device/rr_graph_builder.cpp
Outdated
auto& rr_graph = device_ctx.rr_graph; | ||
size_t v_num = node_storage_.size(); | ||
|
||
if (router_opts.reorder_rr_graph_nodes_algorithm == DONT_REORDER) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if-condition can be done outside this API.
When this API is called, it will definitely do the reordering.
In client functions, we can call the API in this way:
if (router_opts.reorder_rr_graph_nodes_algorithm != DONT_REORDER) {
rr_graph_builder.reorder_nodes();
}
vpr/src/device/rr_graph_builder.cpp
Outdated
@@ -50,3 +53,75 @@ void RRGraphBuilder::add_node_to_all_locs(RRNodeId node) { | |||
void RRGraphBuilder::clear() { | |||
node_lookup_.clear(); | |||
} | |||
|
|||
void RRGraphBuilder::reorder_rr_graph_nodes(const t_router_opts& router_opts) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You may rename the API to be
reorder_nodes()
, which is short and clean. - Instead of using
t_router_opts
, the input argument can be the enumeration of thereorder_rr_graph_nodes_algorithm
. We always avoid to include an overkill data structure as an input arguement.
vpr/src/device/rr_graph_builder.cpp
Outdated
RRNodeId u = que.front(); | ||
que.pop(); | ||
degree[u] += node_storage_.num_edges(u); | ||
for (RREdgeId edge = rr_graph.node_first_edge(u); edge < rr_graph.node_last_edge(u); edge = RREdgeId(size_t(edge) + 1)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node_first_edge()
and node_last_edge()
are APIs of node_storage_
. We do not need to call rr_graph
here.
vpr/src/device/rr_graph_builder.cpp
Outdated
|
||
node_lookup().reorder(dest_order); | ||
|
||
device_ctx.rr_node_metadata.remap_keys([&](int node) { return size_t(dest_order[RRNodeId(node)]); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do the reordering node/edge metadata outside the RRGraphBuilder
, since they are not internal data here.
The dest_order
is the final ordering. @ethanroj23 is already doing the API in his PR #1932
Once his PR is in, you can implement it in this way.
vpr/src/device/rr_graph_builder.h
Outdated
@@ -59,6 +59,20 @@ class RRGraphBuilder { | |||
/** @brief Clear all the underlying data storage */ | |||
void clear(); | |||
|
|||
// Reorder RRNodeId's using one of these algorithms: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the comment style of other APIs, which are compatible with Doxygen.
As such, the API comments will be shown in online documentation.
@tangxifan |
This can be achieved by calling existing API
When @ethanroj23 's PR #1932 is in, we can use the new API from RRGraphView. |
@tangxifan
Okay I am doing using the device_ctx.rr_nodes.size() and once the PR #1932 is complete I will change it accordingly |
@tangxifan, |
The changes make sense to me. Good work @Raza-jafari-RS |
@tangxifan |
@Raza-jafari-RS @umariqbal-rs Thanks for the updates. QoR tests look good. @vaughnbetz I propose to merge. However, I believe it would be great that you can take a quick review on this PR, before I merge. The main point is to see if you agree on
Also, I believe it would be great to add more comments for this API |
Moving a reference to the metadata into the RRGraphBuilder makes sense to me, as you've done so far. @tangxifan: are you proposing to make RRGraphBuilder the owner of the underlying storage too (i.e. move the data, not just a reference, into the RRGraphBuilder)? That might make sense but I haven't looked at the code in detail. @acomodi might know more. @Raza-jafari-RS : I've added some proposed comments giving high-level context on rr-graph reordering (why would it be used?) and metadata. Please incorporate those in the final PR. |
@vaughnbetz Thanks a lot on the comments. Happy new year by the way. This PR has not done so actually. We are still using references in Regarding the final owner of the metadata, I think that I do not have a very strong opinion here. If @acomodi can provide more insights, we can discuss. |
Happy New Year to you too Xifan! |
@tangxifan, vtr-verilog-to-routing/vpr/src/device/rr_graph_view.h Lines 128 to 135 in 1333ba7
|
@Raza-jafari-RS Happy new year. |
@tangxifan |
@Raza-jafari-RS Thanks for the effort. You have applied @vaughnbetz 's comments well. I will wait for @mithro 's inputs before approve on the PR. |
@vaughnbetz @tangxifan Sorry for the late response, anyhow, I have looked a bit through the code, as I wasn't too familiar with For clarity though it might be good to move the following lines just below |
Thanks @acomodi and I agree with you on the comment; we'll want to keep that so it should move if the owner of this data moves. |
@vaughnbetz @acomodi
Let me know if I misunderstand the message. If we do not have any concerns, I suggest to merge this PR as is. |
As discussed today with @mithro , one thing we should keep in mind on the rr_node_metadata: It should be kept separated inside the RRGraphBuilder from other data structures, i.e., We should also add code comments (warnings) to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Raza-jafari-RS Good work. We decide to merge this PR.
We need a follow-up pull request to move the data into RRGraphBuilder. Some rules have to respected. Please check the code comments.
Description
In this PR, I have relocated the reorder_rr_graph_node() from rr_graph_util.cpp to rr_graph_builder.cpp.
Related Issue
Motivation and Context
As it was devised in the node_first_edge() Pull Request discussion.
How Has This Been Tested?
Types of changes
Checklist: