Skip to content

FPGA interchange: add RR graph generation #1999

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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

acomodi
Copy link
Collaborator

@acomodi acomodi commented Mar 16, 2022

Description

This PR adds the RR graph generation, built from the RR interchange data.

The code present in the PR does mainly the following things:

  • reworks and reorganizes some code in common functions to avoid code duplication
  • adds switch to select the RR graph generation from interchange data
  • adds the code to generate the RR graph natively in VTR

Being the Interchange nodes and PIPs information different from the VTR RR graph data model, an intermediate step is required to read and preprocess the interchange data to be suitable for building the RR graph in VTR.

Motivation and Context

One of the missing steps in VTR to enable the Interchange format is to add the RR graph generation.

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 external_libs libarchfpga Library for handling FPGA Architecture descriptions VPR VPR FPGA Placement & Routing Tool labels Mar 16, 2022
@acomodi acomodi force-pushed the acom/fpga-interchange-rr-graph+constants branch from 995f575 to ed6bbd6 Compare March 21, 2022 15:06
@acomodi acomodi changed the title WIP: FPGA interchange: add RR graph generation FPGA interchange: add RR graph generation Mar 21, 2022
@acomodi acomodi requested review from tangxifan and vaughnbetz March 22, 2022 09:49
@acomodi acomodi force-pushed the acom/fpga-interchange-rr-graph+constants branch 3 times, most recently from ed6bbd6 to e686856 Compare April 5, 2022 14:19
mtdudek and others added 18 commits May 2, 2022 09:29
Signed-off-by: Maciej Dudek <[email protected]>
Code refactor

Signed-off-by: Maciej Dudek <[email protected]>
Small improvements to RR graph generation

Signed-off-by: Maciej Dudek <[email protected]>
Signed-off-by: Maciej Dudek <[email protected]>
…on step

Combine node forest to single tree

Signed-off-by: Maciej Dudek <[email protected]>
Update to new mainline

Signed-off-by: Maciej Dudek <[email protected]>
Signed-off-by: Maciej Dudek <[email protected]>
…208f3

54f6208f3 Merge pull request SymbiFlow#69 from antmicro/mdudel/fix_annotations
d8a0567a5 Fix annotations in DeviceResources

git-subtree-dir: libs/EXTERNAL/libinterchange
git-subtree-split: 54f6208f32e20b746863da6ea54e3051fc9a830e
Signed-off-by: Maciej Dudek <[email protected]>
Also fixes RR Graph generation with alternative site types

Signed-off-by: Maciej Dudek <[email protected]>
Signed-off-by: Alessandro Comodi <[email protected]>
@acomodi acomodi force-pushed the acom/fpga-interchange-rr-graph+constants branch from e686856 to f2ae4e5 Compare May 2, 2022 07:30
@acomodi
Copy link
Collaborator Author

acomodi commented May 5, 2022

@vaughnbetz I have fixed formatting, as the PR was red, and everything is passing at the moment. I believe it is ready for an initial review

@vaughnbetz vaughnbetz requested review from amin1377 and vaughnbetz and removed request for vaughnbetz June 23, 2022 15:14
@vaughnbetz
Copy link
Contributor

Adding @amin1377 and @tangxifan as this will be a big one for me to review on my own.

@vaughnbetz
Copy link
Contributor

@tangxifan
Copy link
Contributor

@vaughnbetz No problem. Will do by the end of next week.

Copy link
Contributor

@tangxifan tangxifan left a comment

Choose a reason for hiding this comment

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

@acomodi Some more comments.

  • In the rr_graph build-up, I cannot find any codes to build the edges. If there is, can you point me to it? If no, should we address it in later PR?
  • I also do not find any code to validate the rr_graph once it is finished. Can you double check?

public: /* Validators */
/** 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
* graph. If you need more advance checks, which are related to architecture features, you should
* consider to use the check_rr_graph() function or build your own check_rr_graph() function. */
inline bool validate_node(RRNodeId node_id) const {
return node_storage_.validate_node(node_id, rr_switch_inf_);
}


auto timing_data = ar_.getPipTimings();
arch_->num_switches = seen.size() + 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind to add comments to explain the magic number 2? It looks to me about the hidden switches added by VPR. But not sure about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This +2 is to store MUX and SHORT switch types. arch_->Switches is filled out in process_switches_array function, where SHORT is give id 0 and MUX is given id 1, and rest is used for architecture switches.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll add comment in code explaining this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks. That will help developers a lot!

@@ -2295,10 +2235,10 @@ struct ArchReader {
grid_def.loc_defs.emplace_back(std::move(single));
}

// The constant source tile will be placed at (0, 0)
// The constant source tile will be placed at (1, max_height)
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense to have a fixed layout when using FPGA interchange file format.
Should we comment more about the regulation? Or find a way to document this?

Copy link
Contributor

Choose a reason for hiding this comment

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

In line 2194 fixed grid size is forced, so there is no option to select auto size for FPGA,
but there is no comment about it. Maybe I could add information about this restriction in VPR help for fpga_interchange option? What is your opinion about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. Because this is a restriction, we should have necessary code comments to alert developers.

@@ -258,6 +168,29 @@ static t_pin_to_pin_annotation get_pack_pattern(std::string pp_name, std::string
return pp;
}

static void add_segment_with_default_values(t_segment_inf& seg, std::string name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the default values are consistent with this function

static void ProcessSegments(pugi::xml_node Parent,
std::vector<t_segment_inf>& Segs,
const t_arch_switch_inf* Switches,
const int NumSwitches,
const bool timing_enabled,
const bool switchblocklist_required,
const pugiutil::loc_data& loc_data) {

Should we consider to deposit these value when creating the object?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've looked at this function, and fpga_interchange defaults are different to ones set in xml reader.
So I'm not positive moving default value into object constructor is good idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

O.K. Not a problem to me.

}
}

void fill_switch(t_arch_switch_inf* switch_,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you use template here to be compatible with t_switch_inf and t_rr_switch_inf. Maybe it is better to note in code comments for developers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll add comment that process_switches_array() is template function.

void finish_rr_generation() {
for (t_rr_type rr_type : RR_TYPES)
if (rr_type == CHANX)
device_ctx_.rr_graph_builder.node_lookup().resize_nodes(grid_.height(), grid_.width(), rr_type, NUM_SIDES);
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot find any node registered to the node_lookup().
This may cause router failed due to the needs on node_lookup().find_node().
Can you double check?

Some example:

rr_graph_builder.node_lookup().add_node(inode, chan, start, type, track);

Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I know function finish_rr_generation() is responsible for building node_lookup when running loop in lines 1771 to 1774. Calling add_mode_to_all_locs(node) should be enough to register node in lookup.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. Sorry for missing the details.

Signed-off-by: Maciej Dudek <[email protected]>
@mtdudek
Copy link
Contributor

mtdudek commented Jul 12, 2022

@tangxifan RR graph correctness is checked by running check_rr_graph() at the end of build_rr_graph_fpga_interchange.
As far as I understand RR edges are CHANX/CHANY, site to CHANs connections. The main function that process fpga_interchange nodes to CHAN(X|Y)s is process_nodes, it iterates over FPGA Interchange nodes and then computes virtual placements. Later in virtual_to_real virtual mapping is resolved and finally in pack_chans_edges CHANS are packed into RR graph.

Copy link
Contributor

@tangxifan tangxifan left a comment

Choose a reason for hiding this comment

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

@mtdudek Changes look good to me. Just need some code comments to be added.

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.

Is there a spot I can look for the overall comment (big one) on how the architecture interchange format works with vtr, and for pointers to the arch interchange format documentation? I don't see any such large scale comment in this PR -- is it already in the code somewhere else? If so, please point me at it, and if not, please add such a comment.

I suspect that some more high-level commenting on the overall arch interchange interface (what is getting built when) is needed, along with pointers to bel, pip etc. definitions and how they are used in the architecture interchange format. But maybe those are already in the code base and I just am not familiar with where to look.


device_ctx_.rr_graph_builder.init_fan_in();

// Creates a temporary copy to convert from vtr::vector to sitd::vector.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo:
std::vector
Should also file an issue to track changing alloc_and_load_rr_indexed_data to a vtr::vector

int* wire_to_rr_ipin_switch,
std::string& read_rr_graph_filename,
bool do_check_rr_graph);

Copy link
Contributor

Choose a reason for hiding this comment

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

Add comment saying we need to hash tuples (and why) and that the following utility functions achieve that.

VCC,
};

enum node_sides {
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment what these are used for. Side of a block that an rr_node is on? Or something else?

@@ -1480,7 +1480,9 @@ argparse::ArgumentParser create_arg_parser(std::string prog_name, t_options& arg
.help(
"File format for the input atom-level circuit/netlist.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment looks wrong -- it's not the atom-level circuit/netlist but the arch file we're talking about here.

@oscarcheng105 oscarcheng105 mentioned this pull request Sep 2, 2022
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external_libs libarchfpga Library for handling FPGA Architecture descriptions VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants