Skip to content

Now rr_graph -related source files are placed in a separated library librrgraph #1972

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 21 commits into from
Feb 22, 2022

Conversation

tangxifan
Copy link
Contributor

@tangxifan tangxifan commented Feb 11, 2022

Description

This PR creates a C++ library of routing resource graph -related data structures.

Related Issue

Address issue #1868

Motivation and Context

Previously, data structures are tightly integrated with the VPR source codes (part of the router)
However, we see a strong motivation in creating a C++ library for the routing resource graph data structures.
This is because the routing resource graph is part of device modeling which should be decoupled with any EDA engines.
The benefits include

  • Decouple routing resource graph data structure from routers as well as other codes of VPR
  • Easier to profiling the data structure by runtime and peak memory usage. So that we can improve the data structure easily

How Has This Been Tested?

This PR includes the following changes

  • Move rr_graph data structures from vpr/src to libs/librrgraph
  • Clean-up all the APIs by removing all the dependencies on VPR global variables
  • Move all the data types for routing resource graph to a separated header file rr_node_types.h. (Name of the file can be changed)
  • Change all the error API from VPR_FATAL_ERROR to VTR_LOG_ERROR
  • Change documentation to track the code comments in libs/librrgraph

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

@tangxifan tangxifan changed the title Now rr_graph -related source files are placed in a separated library librrgraph [WIP] Now rr_graph -related source files are placed in a separated library librrgraph Feb 11, 2022
@github-actions github-actions bot added the VPR VPR FPGA Placement & Routing Tool label Feb 11, 2022
@tangxifan
Copy link
Contributor Author

tangxifan commented Feb 11, 2022

@umariqbal-rs Can you look into the doc errors:

image

Also if CI is green, can you run QoR tests? This time, it is better to test on different machines and see if there are any degradation. We are very sensitive to performance degradation in this PR.

@umariqbal-rs
Copy link
Contributor

@tangxifan
Sure I will do them.

@mithro
Copy link
Contributor

mithro commented Feb 11, 2022

Would be good to get someone from Antmicro like @acomodi or @kgugala to review this change to understand if / how this will affect SymbiFlow.

@tangxifan
Copy link
Contributor Author

@mithro Yes. It will be great. I have requested their review.

@umariqbal-rs
Copy link
Contributor

@tangxifan
I think there is an issue in Cmake can you Please have a look?
image

@tangxifan
Copy link
Contributor Author

@tangxifan I think there is an issue in Cmake can you Please have a look? image

Emm. Weird that CI does not capture it. Can you show your CMake version?
Also comment out LINE11. It should work then.

@umariqbal-rs
Copy link
Contributor

@tangxifan
cmake version 3.16.2

@umariqbal-rs
Copy link
Contributor

@tangxifan I think there is an issue in Cmake can you Please have a look? image

Emm. Weird that CI does not capture it. Can you show your CMake version? Also comment out LINE11. It should work then.

Thanks It works after commenting line 11.

Copy link
Collaborator

@acomodi acomodi left a comment

Choose a reason for hiding this comment

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

LGTM, I think that SymbiFlow won't be affected by these changes, also confirmed by the passing symbiflow tests

Comment on lines -260 to +266
edge_idx_range configurable_edges(const RRNodeId& id) const {
return vtr::make_range(edge_idx_iterator(0), edge_idx_iterator(num_edges(id) - num_non_configurable_edges(id)));

edge_idx_range configurable_edges(const RRNodeId& id, const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches) const {
return vtr::make_range(edge_idx_iterator(0), edge_idx_iterator(num_edges(id) - num_non_configurable_edges(id, rr_switches)));
}
edge_idx_range non_configurable_edges(const RRNodeId& id) const {
return vtr::make_range(edge_idx_iterator(num_edges(id) - num_non_configurable_edges(id)), edge_idx_iterator(num_edges(id)));
edge_idx_range non_configurable_edges(const RRNodeId& id, const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches) const {
return vtr::make_range(edge_idx_iterator(num_edges(id) - num_non_configurable_edges(id, rr_switches)), edge_idx_iterator(num_edges(id)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose that the call to the edge partitioning in configurable/non-configurable edges has already been executed before calling these functions. Even though this change does not modify the previous behavior, it may be worth adding assertions here though, to check that the partitioned_ flag has been set, and put it under an assert_safe if we want to avoid any kind of overhead (not sure how often these are called).

Copy link
Contributor Author

@tangxifan tangxifan Feb 14, 2022

Choose a reason for hiding this comment

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

@acomodi Agree. I just double check the APIs.
When calling num_configurable_edges() and num_non_configurable_edges(), the internal flags are checked to ensure edges are already partitioned. It is not exactly the partition_ flag but something equivalent (assigned during partition_edges() API call).
Let me know if this is sufficient or not.

t_edge_size t_rr_graph_storage::num_configurable_edges(RRNodeId id, const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches) const {
VTR_ASSERT(!node_first_edge_.empty() && remapped_edges_);

void t_rr_graph_storage::partition_edges(const vtr::vector<RRSwitchId, t_rr_switch_inf>& rr_switches) {
if (partitioned_) {
return;
}
edges_read_ = true;
VTR_ASSERT(remapped_edges_);
// This sort ensures two things:
// - Edges are stored in ascending source node order. This is required
// by assign_first_edges()
// - Edges within a source node have the configurable edges before the
// non-configurable edges.
std::sort(
edge_sort_iterator(this, 0),
edge_sort_iterator(this, edge_src_node_.size()),
edge_compare_src_node_and_configurable_first(rr_switches));
partitioned_ = true;
assign_first_edges();
VTR_ASSERT_SAFE(validate(rr_switches));
}

@umariqbal-rs
Copy link
Contributor

umariqbal-rs commented Feb 17, 2022

@tangxifan
QoR tests are completed with current Master and quick summary is given below. QoR comparison files are also attached.
vtr_reg_qor_chain_depop test:
Flow run time 2.91% on average.
critical path delay 0% on average.
Peak memory usage 0.06% on average
titan_quick_qor test:
flow run time 3.29% on average.
critical path delay 0% on average.
Peak memory usage -0.13% on average
titan_quick_qor.xlsx
vtr_reg_qor_chain_depop.xlsx

@tangxifan
Copy link
Contributor Author

@umariqbal-rs Can you upload the spreadsheets? Is it on a machine or two machines?

@umariqbal-rs
Copy link
Contributor

@umariqbal-rs Can you upload the spreadsheets? Is it on a machine or two machines?

I already did .
We will upload tomorrow the second one.

@tangxifan
Copy link
Contributor Author

@umariqbal-rs We have discussed the PR today with @vaughnbetz
He thinks the PR is good in terms of code changes and QoR tests are acceptable.
Please

  • Fix the broken links in the documentation
  • Upload the QoR tests from the 2nd machine

Then we can merge this PR.

typedef enum e_rr_type : unsigned char {
SOURCE = 0, ///<A dummy node that is a logical output within a block -- i.e., the gate that generates a signal.
SINK, ///<A dummy node that is a logical input within a block -- i.e. the gate that needs a signal.
IPIN,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest adding comment for each enum.
IPIN: input pin to a block
OPIN: output pin of a block
CHANX: x-directed routing wire, or an x-directed segment of a channel for global routing
CHANY: y-directed routing wire, or a y-directed segment of a channel for global routing

float C;
};

//[0..num_rr_types-1][0..grid_width-1][0..grid_height-1][0..NUM_SIDES-1][0..max_ptc-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should comment what this is for (fast lookups of an rr-node given an (rr_type, x, y, and the side).

@vaughnbetz
Copy link
Contributor

Code looks good; I had a few minor suggestions on commenting above; can address after merging if you prefer.

@tangxifan
Copy link
Contributor Author

@vaughnbetz No worries

@umariqbal-rs Please refine code comments as suggested.

@tangxifan tangxifan changed the title [WIP] Now rr_graph -related source files are placed in a separated library librrgraph Now rr_graph -related source files are placed in a separated library librrgraph Feb 19, 2022
@behzadmehmood-rs
Copy link
Contributor

@tangxifan
QoR tests are completed with current Master on second server and quick summary is given below. QoR comparison files are also attached.
vtr_reg_qor_chain_depop test:
Flow run time -0.38% on average.
critical path delay 0% on average.
Peak memory usage -0.03% on average
titan_quick_qor test:
flow run time 0.11% on average.
critical path delay 0% on average.
Peak memory usage 0% on average
titan_quick_qor_master.xlsx
vtr_reg_qor_chain_depop.xlsx

@tangxifan
Copy link
Contributor Author

Thanks @behzadmehmood-rs for the updates. QoR looks good to me.

@vaughnbetz I have updated the comments and fixed the broken links in documentation on the RRGraph APIs.
I propose to merge as QoR results are also clean.
If you have any further comments. Feel free to shot, we will address it in follow-up pull requests.

@tangxifan tangxifan merged commit 8e7efe5 into master Feb 22, 2022
@tangxifan tangxifan deleted the librrgraph branch February 22, 2022 05:39
@tangxifan tangxifan restored the librrgraph branch February 22, 2022 05:39
@tangxifan tangxifan deleted the librrgraph branch February 22, 2022 05:39
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.

6 participants