-
Notifications
You must be signed in to change notification settings - Fork 414
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
Remove usage of atom to pb lookup from packing #2932
Conversation
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.
This lock ensures that the atom_pb_bimap structure in global context is not accessed in packing.
On a kind of unrelated note: Why are there three different find_pb_graph_pin functions? In TimingGraphBuilder, vpr_utils.cpp and PreClusterDelayCalculator. |
@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. |
There was a problem hiding this 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).
954a9e2
to
8d801d7
Compare
Hi @AlexandreSinger, thanks for the review! I did some more changes based on your comments, do you mind taking another look? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
vpr/src/base/atom_lookup.h
Outdated
@@ -25,29 +27,49 @@ class AtomLookup { | |||
|
|||
typedef vtr::Range<pin_tnode_iterator> pin_tnode_range; | |||
|
|||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: extra spaces.
vpr/src/pack/atom_pb_bimap.cpp
Outdated
|
||
void AtomPBBimap::reset_bimap(const AtomNetlist &netlist) { | ||
for (auto blk : netlist.blocks()) { | ||
set_atom_pb(blk, nullptr); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
vpr/src/pack/cluster_legalizer.cpp
Outdated
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; |
There was a problem hiding this comment.
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.
vpr/src/pack/cluster_legalizer.cpp
Outdated
"\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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style changes.
vpr/src/pack/cluster_legalizer.cpp
Outdated
"\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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
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.
vpr/src/pack/cluster_legalizer.cpp
Outdated
// 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()); |
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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.
vpr/src/pack/pack.cpp
Outdated
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()); |
There was a problem hiding this comment.
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.
Oh btw I tried to remove the is_blom_blk function completely and somehow the tests weren't passing. Not sure why. |
There was a problem hiding this 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.
8f5404f
to
f77c3c7
Compare
ccb2396
into
verilog-to-routing:master
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.