Skip to content

rr_nodes: add fan-in list generator #1592

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

Conversation

acomodi
Copy link
Collaborator

@acomodi acomodi commented Nov 12, 2020

Signed-off-by: Alessandro Comodi [email protected]

Description

It might be useful to get only the fan-in edges of a certain destination node, and currently the RR graph APIs do not provide such a possibility.

This PR adds a fan-in list constructor and its destroyer so that the extra memory is freed once the purpose of the fan-in lists has been fulfilled.

Related Issue

Motivation and Context

How Has This Been Tested?

Types of changes

  • Bug fix (change which fixes an issue)
  • New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@github-actions github-actions bot added the VPR VPR FPGA Placement & Routing Tool label Nov 12, 2020
Copy link
Contributor

@vaughnbetz vaughnbetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just have a few suggestions (most important of which is a not-loaded check).
I think we should also add a test of this to a unit test if possible (I think we have some rr-graph unit tests already, which would make this pretty easy to add).

@@ -633,6 +645,9 @@ class t_rr_graph_storage {
// Fan in counts for each RR node.
vtr::vector<RRNodeId, t_edge_size> node_fan_in_;

// Fan in edges for each RR node.
vtr::vector<RRNodeId, std::vector<RREdgeId>> node_fan_in_list_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's good to add a comment saying this data is only created on demand (not with the rest of the rr_graph) and can be destroyed on demand.

@@ -747,6 +764,11 @@ class t_rr_graph_view {
return node_fan_in_[id];
}

/* Retrieve fan_in edges vector for RRNodeId. */
std::vector<RREdgeId> fan_in_list(RRNodeId id) const {
return node_fan_in_list_[id];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should put a check for the fan_in_list not being loaded here (id out of vector range) with an error message saying it doesn't appear to be loaded.

node_fan_in_list_.shrink_to_fit();

//Walk the graph and increment fanin on all dwnstream nodes
for (const auto& edge_id : edge_dest_node_.keys()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If node_fan_in (count of incoming edges) has already been loaded (should have been since we don't appear to have a separate free_ call for it) then you can make this a bit more memory-efficient by getting the right size of vector storage by doing something like the below before the main edge loop that loads the vectors.

 for (const auto& edge_id : edge_dest_node_.keys()) {
       node_fan_in_list_[edge_id].reserve(node_fan_in[edge_id];
   }

@@ -393,6 +393,24 @@ void t_rr_graph_storage::init_fan_in() {
}
}

void t_rr_graph_storage::init_fan_in_list() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this can be computed using the public interface, just make this a utility class that lives outside of t_rr_graph_storage completely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this can be computed using the public interface (unless I am missing something). This method requires the edge_dest_node_ vector, which is private to the graph storage

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for_each_edge should work here?

@acomodi acomodi force-pushed the add-fan-in-edges-generation branch from d1b53fc to 8cea5b3 Compare November 13, 2020 12:17
@acomodi acomodi force-pushed the add-fan-in-edges-generation branch from 8cea5b3 to 1a7fd21 Compare November 13, 2020 15:33
@acomodi acomodi changed the title rr_nodes: add fan-in list constructor/destroyer rr_nodes: add fan-in list generator Nov 13, 2020
Copy link
Collaborator

@litghost litghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@acomodi acomodi force-pushed the add-fan-in-edges-generation branch from 1a7fd21 to 73c5be9 Compare November 13, 2020 18:41
@vaughnbetz
Copy link
Contributor

Looks good to me. Merging.

@vaughnbetz vaughnbetz merged commit 78807c7 into verilog-to-routing:master Nov 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants