-
Notifications
You must be signed in to change notification settings - Fork 415
Refactoring clustering/packing code and building re-cluster API #2034
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
…assed from packing to placement
…r_test - the test need to be undated
All the current check failures are due to cloud resource issues. I will re-run the failing tests in the evening (tried that yesterday and all the tests passed). It seems that the cloud is less loaded in the evening. If it's green, I will merge it in the early morning tomorrow. |
std::unordered_map<AtomBlockId, t_pb_graph_node*> expected_lowest_cost_pb_gnode; //The molecules associated with each atom block | ||
const t_model* cur_model; | ||
int num_models; | ||
t_clustering_data clustering_data; | ||
//int num_models; |
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.
maybe remove these lines instead of commenting them
const int pack_pattern_index, | ||
AtomBlockId blk_id) { | ||
t_pack_molecule* molecule; | ||
|
||
//auto& atom_ctx = g_vpr_ctx.atom(); |
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.
remove commented line
std::unordered_map<AtomBlockId, t_pb_graph_node*>& expected_lowest_cost_pb_gnode, | ||
const int num_packing_patterns); | ||
|
||
void free_pack_molecules(t_pack_molecule* list_of_pack_molecules); | ||
//void free_pack_molecules(t_pack_molecule* list_of_pack_molecules); |
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.
remove commented line
/** | ||
* @file | ||
* @brief This files defines some helper functions for the re-clustering | ||
* |
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.
Maybe add some context to this comment - why would we want to re-do clusters, what situations would that be beneficial in?
@@ -1057,6 +1063,14 @@ static void placement_inner_loop(const t_annealing_state* state, | |||
blocks_affected, delay_model, criticalities, setup_slacks, | |||
placer_opts, move_type_stat, place_algorithm, timing_bb_factor, manual_move_enabled); | |||
|
|||
/* |
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.
Remove this debugging code
@@ -1215,6 +1229,14 @@ static float starting_t(const t_annealing_state* state, t_placer_costs* costs, t | |||
placer_opts, move_type_stat, placer_opts.place_algorithm, | |||
REWARD_BB_TIMING_RELATIVE_WEIGHT, manual_move_enabled); | |||
|
|||
/******************** Elgammal ************************/ | |||
/* | |||
* auto& atom_ctx = g_vpr_ctx.atom(); |
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.
remove debugging code if no longer needed
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 code looks good to me overall. I think you can remove some unnecessary lines in a new pull request, and also add more context to the comment about the re-clustering API.
Thanks @sfkhalid for the review. As per our conversation yesterday, I will land this now and address your comments on a new PR so that you can work on debugging the tests on the master branch. |
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.
To apply to the latest code.
Sarah's unit tests: seem to be full flow tests --> maybe better as command line reg tests as usual?
@@ -55,12 +55,18 @@ struct AtomContext : public Context { | |||
/******************************************************************** | |||
* Atom Netlist | |||
********************************************************************/ | |||
|
|||
AtomContext() | |||
: list_of_pack_molecules(nullptr, free_pack_molecules) {} | |||
///@brief Atom netlist | |||
AtomNetlist nlist; | |||
|
|||
///@brief Mappings to/from the Atom Netlist to physically described .blif models | |||
AtomLookup lookup; |
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.
Beef up this comment. How do you use this mapping? What is its lifetime (valid only after clustering)?
///@brief The molecules associated with each atom block | ||
std::multimap<AtomBlockId, t_pack_molecule*> atom_molecules; | ||
|
||
std::unique_ptr<t_pack_molecule, decltype(&free_pack_molecules)> list_of_pack_molecules; |
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.
Add a comment -- what is this for? (head of a linked list of all the molecules -- used to free them).
@@ -259,6 +265,26 @@ struct ClusteringContext : public Context { | |||
*/ | |||
std::map<ClusterBlockId, std::map<int, ClusterNetId>> post_routing_clb_pin_nets; | |||
std::map<ClusterBlockId, std::map<int, int>> pre_routing_net_pin_mapping; | |||
|
|||
std::map<t_logical_block_type_ptr, size_t> num_used_type_instances; |
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.
Comment this. What is it and what's it for?
std::map<t_logical_block_type_ptr, size_t> num_used_type_instances; | ||
}; | ||
|
||
struct ClusteringHelperContext : public Context { |
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.
Comment this struct/context -- what is it for, what's it's lifetime?
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.
Explain variables at least at high level (if you don't know them all then can say they're needed during the seed-based clusterer? Or needed for any clustering changes?)
@@ -1654,4 +1654,9 @@ class RouteStatus { | |||
|
|||
typedef vtr::vector<ClusterBlockId, std::vector<std::vector<int>>> t_clb_opins_used; //[0..num_blocks-1][0..class-1][0..used_pins-1] | |||
|
|||
typedef std::vector<std::map<int, int>> t_arch_switch_fanin; | |||
|
|||
void free_pack_molecules(t_pack_molecule* list_of_pack_molecules); |
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.
Comment these if you can.
*/ | ||
|
||
/** | ||
* @brief A function that returns the cluster ID of an atom 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.
Is the cluster id the block id in the clustered netlist?
std::vector<AtomBlockId> cluster_to_atoms(const ClusterBlockId& cluster); | ||
|
||
/** | ||
* @brief A function that loads the router data for a cluster |
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.
intra-cluster router
* | ||
* It returns true if the removal is done and the old cluster is legal. | ||
* It aborts the removal and returns false if the removal will make the old cluster | ||
* illegal |
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.
An empty cluster is considered illegal (?)
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.
Re-order parameters to have inputs , then state that is input/output and then outputs.
Comment exactly what is returned, including reference parameters.
/** | ||
* @brief A function that starts a new cluster for one specific molecule | ||
* | ||
* It place the molecule in a specific type and mode that should be passed by |
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.
Same comment : comment inputs, outputs, etc.
inputs first, outputs second in parameter list.
Do we need pad_loc_type?
You're passing in an atom, but the comment is about molecules. (update comment if necessary)
bool during_packing); | ||
|
||
/** | ||
* @brief A function that fix the clustered netlist if the move is performed |
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.
If you can, explain what this fix is (at a high level).
When should this be called? After any change to any cluster after packing is done?
Description
In this pull request, the first function of re-cluster is implemented. This API should allow the users to change clustering decisions after the clustering is done. These changes can be done during packing or placement.
Multiple refactoring steps were done to the original clustering code to build this API.
The first function in the API implemented in this PR can move an atom out of a cluster and create a new cluster for it. More Functions for this API are to be implemented in upcoming PRs.
The function was tested on VTR benchmarks and unit tests will be added when the API is completed in the upcoming PRs.
Related Issue
Being not able to change the clustering decision later in the flow caused suboptimality in the generated placed design.
Motivation and Context
How Has This Been Tested?
The refactor shows no change to QoR. Some examples are extracted for the CI runs comparing the branch to master with no change attached here
Types of changes
Checklist: