Skip to content

Remove usage of atom to pb lookup from packing #2932

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

Conversation

AmirhosseinPoolad
Copy link
Contributor

Adds new AtomPBLookUp class that holds the atom to/from pb lookup data in the cluster legalizer class. The packing stage now uses that instead of the global context. At the end of packing, AtomPBLookUp gets copied to the global context and everything goes on as normal.

To keep this invariant from being changed in the future, a lock was added to prevent any access to the atom pb data.

AmirhosseinPoolad and others added 2 commits March 12, 2025 19:08
Adds new AtomPBLookUp class that holds the atom to/from lookup data
in the cluster legalizer class. The packing stage now uses that instead
of the global context. At the end of packing, AtomPBLookUp gets copied
to the global context and everything goes on as normal.
@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Mar 12, 2025
@AmirhosseinPoolad
Copy link
Contributor Author

On a kind of unrelated note: Why are there three different find_pb_graph_pin functions? In TimingGraphBuilder, vpr_utils.cpp and PreClusterDelayCalculator.

@AmirhosseinPoolad
Copy link
Contributor Author

@AlexandreSinger I want to run the nightly tests on this branch before merging, but meanwhile can you take a look at this? I'm done doing the obvious clean ups and fixes.

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.

@AmirhosseinPoolad Thank you so much for this cleanup. It was desperately needed. I think we are getting close to removing this lookup entirely in the packer. I had some comments throughout. Be careful when you rebase onto a very large change like Soheil's formatting change. It can really cause havoc on PRs like this and it will undo Soheil's changes.

I recommend letting Vaughn review this PR as well (when he gets back).

@AmirhosseinPoolad AmirhosseinPoolad force-pushed the refactor_atom_pb_from_packing branch from 954a9e2 to 8d801d7 Compare March 17, 2025 17:18
@AmirhosseinPoolad
Copy link
Contributor Author

Hi @AlexandreSinger, thanks for the review! I did some more changes based on your comments, do you mind taking another look? Thanks.

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.

Hi @AmirhosseinPoolad

This is coming along great! I agree with your changes so far. I do have some more comments. There are also some comments I made before which I think still need to be addressed.

@@ -25,29 +27,49 @@ class AtomLookup {

typedef vtr::Range<pin_tnode_iterator> pin_tnode_range;



Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: extra spaces.


void AtomPBBimap::reset_bimap(const AtomNetlist &netlist) {
for (auto blk : netlist.blocks()) {
set_atom_pb(blk, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the atom_to_pb_ bimap not have a clear method? Or do we have to set each element to nullptr to clear it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does have one. The reason I didn't use it is at first I thought this was a "just set to nullptr but don't actually erase the data structure" which wouldn't be the same thing as calling clear, but the code for set_atom_pb does actually erase the data structure if one of the arguments is nullptr so it should be equivalent.

pb->pb_stats->lookahead_input_pins_used = std::vector<std::vector<AtomNetId>>(pb->pb_graph_node->num_input_pin_class);
pb->pb_stats->lookahead_output_pins_used = std::vector<std::vector<AtomNetId>>(pb->pb_graph_node->num_output_pin_class);
pb->pb_stats->num_child_blocks_in_pb = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Some style change conflicts that you should probably revert.

"\t\t\t Intersect: Atom block %d has no floorplanning constraints\n",
atom_blk_id);
"\t\t\t Intersect: Atom block %d has no floorplanning constraints\n",
atom_blk_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Style changes.

"\t\t\t NoC Group: Atom block %d passed cluster, cluster's NoC group was compatible with the atom's group %d\n",
atom_blk_id, (size_t)atom_noc_grp_id);
"\t\t\t NoC Group: Atom block %d passed cluster, cluster's NoC group was compatible with the atom's group %d\n",
atom_blk_id, (size_t)atom_noc_grp_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not going to mark every single one. Go through the file and ensure you are not undoing Soheil's changes.

// Copy the options passed by the user
cluster_legalization_strategy_ = cluster_legalization_strategy;
enable_pin_feasibility_filter_ = enable_pin_feasibility_filter;
log_verbosity_ = log_verbosity;
atom_pb_lookup_ = AtomPBBimap(g_vpr_ctx.atom().lookup().atom_pb_bimap());
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think this is the case. Does the atom_pb_bimap have the ability to tell if it is empty or not?

if (cluster_legalizer.get_atom_cluster(blk_id) == legalization_cluster_id
&& is_atom_blk_in_pb(blk_id, atom_ctx.lookup().atom_pb(clustered_blk_id))) {
&& cluster_legalizer.is_atom_blk_in_cluster_block(blk_id, clustered_blk_id)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am nervous to leave this code in. is_atom_blk_in_cluster_block does not really make sense when it takes two atoms as arguments. I worry this will stay around for a long time. I think this either should be investigated or we keep the "is_atom_blk_in_pb" method.

g_vpr_ctx.mutable_atom().mutable_lookup().set_atom_clb(blk, ClusterBlockId::INVALID());
g_vpr_ctx.mutable_atom().mutable_lookup().set_atom_pb(blk, nullptr);
}
cluster_legalizer.mutable_atom_pb_lookup().reset_bimap(g_vpr_ctx.atom().netlist());
Copy link
Contributor

Choose a reason for hiding this comment

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

The cluster legalizer has a reset method which is called in line 303 below. I recommend putting this in there.

@AmirhosseinPoolad
Copy link
Contributor Author

Oh btw I tried to remove the is_blom_blk function completely and somehow the tests weren't passing. Not sure why.

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.

LGTM! Very well done on this PR Amir; sorry for all the comments. This is a tricky bit of code.

Please resolve the conflicts and ensure it passes CI and then I think this can be merged.

@AmirhosseinPoolad AmirhosseinPoolad force-pushed the refactor_atom_pb_from_packing branch from 8f5404f to f77c3c7 Compare March 20, 2025 17:05
@AmirhosseinPoolad AmirhosseinPoolad merged commit ccb2396 into verilog-to-routing:master Mar 20, 2025
36 checks passed
@AmirhosseinPoolad AmirhosseinPoolad deleted the refactor_atom_pb_from_packing branch May 9, 2025 18:06
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.

2 participants