Skip to content

Conversation

@amin1377
Copy link
Contributor

@amin1377 amin1377 commented Dec 1, 2025

This PR adds a schema file ID to the RR graph attributes. The ID is included in both the XML and Cap’n Proto (binary) formats. When reading an RR graph, VTR now loads the schema ID stored in its internal schema and compares it with the ID found in the XML or binary file. If the IDs do not match, an error is raised.

@AlexandreSinger: I believe this also addresses your earlier concern about including an ID for the XML file.

Below is the first line of the RR graph XML, showing the added schema ID:

image

For the Cap’n Proto file: each time the schema is generated, Cap’n Proto assigns a random 64-bit number in the format @0x.... This number is stored as the schema ID in both the XML and binary RR graph files.

@github-actions github-actions bot added the lang-cpp C/C++ code label Dec 1, 2025
@amin1377
Copy link
Contributor Author

amin1377 commented Dec 1, 2025

Note that if an XML file does not contain this attribute, it can still be read. An error is raised only when the schema_id attribute is present and does not match the schema used by VPR.

Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

Thanks Amin! Some minor comments below.

So, just to confirm, if the XML file does not have this attribute, this code will not error out? My concern is that many users of VTR generate the RR-graph XML using external tools. So is our solution to this is just to tell them not to set this attribute? That way they "opt-out" of this error checking.

@amin1377
Copy link
Contributor Author

amin1377 commented Dec 3, 2025

Thanks Amin! Some minor comments below.

So, just to confirm, if the XML file does not have this attribute, this code will not error out? My concern is that many users of VTR generate the RR-graph XML using external tools. So is our solution to this is just to tell them not to set this attribute? That way they "opt-out" of this error checking.

Yes, you are right. If this attribute doesn't exist in XML file, we don't error out.

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.

A few minor changes

*/
inline void set_rr_graph_schema_file_id(unsigned long schema_file_id, void*& /*ctx*/) final {
// Only check if the schema file ID is not 0. If it is 0, it means capnproto is not enabled.
// Thus, we cannot check the schema file ID mismatch.
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 this comment moment is incomplete. Don’t you also allow older rr graphs with no schema to come in? Might also want the to explain that we’re checking the file is compatible when can, but alllowing it to be read if we can’t determine its schema

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the comment to the following:

// Only check if schema_file_id_ (set when initializing the class) is not 0.
// If it is 0, it means Cap'n Proto is not enabled, so we cannot check for a schema file ID mismatch.
// This function is only called when the RR graph file being read contains a schema file ID.
// If it does not, this function is not called, and the RR graph can be read without performing
// the schema file ID check.

@github-actions github-actions bot added the VPR VPR FPGA Placement & Routing Tool label Dec 4, 2025
@amin1377
Copy link
Contributor Author

amin1377 commented Dec 4, 2025

Thanks @vaughnbetz and @AlexandreSinger for your review. I’ve addressed your comments. Please let me know if you have any further feedback.

Copy link
Contributor

@AlexandreSinger AlexandreSinger left a comment

Choose a reason for hiding this comment

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

Thanks @amin1377 LGTM!

I am happy that the RR graph writer now has access to the route verbosity as well.

@AlexandreSinger AlexandreSinger merged commit 17bf401 into master Dec 4, 2025
30 checks passed
@AlexandreSinger AlexandreSinger deleted the add_capnp_hash branch December 4, 2025 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants