Skip to content

Commit 9bdc971

Browse files
committed
Refactored the way attraction group molecules are added when looking for the highest gain molecule
1 parent 553766b commit 9bdc971

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

vpr/src/pack/cluster.cpp

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,25 +2631,14 @@ static t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
26312631

26322632
/* Grab highest gain molecule */
26332633
t_pack_molecule* molecule = nullptr;
2634-
if (cur_pb->pb_stats->num_feasible_blocks > 0) {
2635-
cur_pb->pb_stats->num_feasible_blocks--;
2636-
int index = cur_pb->pb_stats->num_feasible_blocks;
2637-
molecule = cur_pb->pb_stats->feasible_blocks[index];
2638-
VTR_ASSERT(molecule->valid == true);
2639-
return molecule;
2640-
}
2641-
2642-
/*
2643-
* No suitable molecules were found from the above functions - if
2644-
* attraction groups were created, explore the attraction groups to see if
2645-
* any suitable molecules can be found.
2646-
*/
2647-
int num_pulls = attraction_groups.get_att_group_pulls();
2648-
2649-
if (cur_pb->pb_stats->pulled_from_atom_groups < num_pulls) {
2650-
add_cluster_molecule_candidates_by_attraction_group(cur_pb, cluster_placement_stats_ptr, atom_molecules, attraction_groups,
2651-
feasible_block_array_size, cluster_index, primitive_candidate_block_types);
2652-
cur_pb->pb_stats->pulled_from_atom_groups++;
2634+
if (cur_pb->pb_stats->num_feasible_blocks == 0) {
2635+
/*
2636+
* No suitable molecules were found from the above functions - if
2637+
* attraction groups were created, explore the attraction groups to see if
2638+
* any suitable molecules can be found.
2639+
*/
2640+
add_cluster_molecule_candidates_by_attraction_group(cur_pb, cluster_placement_stats_ptr, atom_molecules, attraction_groups,
2641+
feasible_block_array_size, cluster_index, primitive_candidate_block_types);
26532642
}
26542643

26552644
if (cur_pb->pb_stats->num_feasible_blocks > 0) {
@@ -2738,6 +2727,9 @@ static void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur
27382727
* If the current cluster being packed has an attraction group associated with it
27392728
* (i.e. there are atoms in it that belong to an attraction group), this routine adds molecules
27402729
* from the associated attraction group to the list of feasible blocks for the cluster.
2730+
* Attraction groups can be very large, so we only add some randomly selected molecules for efficiency
2731+
* if the number of atoms in the group is greater than 500. Therefore, the molecules added to the candidates
2732+
* will vary each time you call this function.
27412733
*/
27422734
static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
27432735
t_cluster_placement_stats* cluster_placement_stats_ptr,
@@ -2751,6 +2743,22 @@ static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
27512743

27522744
auto cluster_type = cluster_ctx.clb_nlist.block_type(clb_index);
27532745

2746+
/*
2747+
* For each cluster, we want to explore the attraction group molecules as potential
2748+
* candidates for the cluster a limited number of times. This limit is imposed because
2749+
* if the cluster belongs to a very large attraction group, we could potentially search
2750+
* through its attraction group molecules for a very long time.
2751+
* Defining a number of times to search through the attraction groups (i.e. number of
2752+
* attraction group pulls) determines how many times we search through the cluster's attraction
2753+
* group molecules for candidate molecules.
2754+
*/
2755+
int num_pulls = attraction_groups.get_att_group_pulls();
2756+
if (cur_pb->pb_stats->pulled_from_atom_groups < num_pulls) {
2757+
cur_pb->pb_stats->pulled_from_atom_groups++;
2758+
} else {
2759+
return;
2760+
}
2761+
27542762
AttractGroupId grp_id = cur_pb->pb_stats->attraction_grp_id;
27552763
if (grp_id == AttractGroupId::INVALID()) {
27562764
return;
@@ -2769,6 +2777,7 @@ static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
27692777
VTR_ASSERT(itr != primitive_candidate_block_types.end());
27702778
std::vector<t_logical_block_type_ptr>& candidate_types = itr->second;
27712779

2780+
//Only consider molecules that are unpacked and of the correct type
27722781
if (atom_ctx.lookup.atom_clb(atom_id) == ClusterBlockId::INVALID()
27732782
&& std::find(candidate_types.begin(), candidate_types.end(), cluster_type) != candidate_types.end()) {
27742783
auto rng = atom_molecules.equal_range(atom_id);
@@ -2802,6 +2811,7 @@ static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
28022811
VTR_ASSERT(itr != primitive_candidate_block_types.end());
28032812
std::vector<t_logical_block_type_ptr>& candidate_types = itr->second;
28042813

2814+
//Only consider molecules that are unpacked and of the correct type
28052815
if (atom_ctx.lookup.atom_clb(blk_id) == ClusterBlockId::INVALID()
28062816
&& std::find(candidate_types.begin(), candidate_types.end(), cluster_type) != candidate_types.end()) {
28072817
auto rng = atom_molecules.equal_range(blk_id);

0 commit comments

Comments
 (0)