Skip to content

Commit f262a97

Browse files
committed
Added comments to clarify attraction groups-related code
1 parent 1ae7dc3 commit f262a97

File tree

3 files changed

+58
-51
lines changed

3 files changed

+58
-51
lines changed

vpr/src/pack/attraction_groups.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ AttractionInfo::AttractionInfo() {
3636
}
3737
}
3838

39-
AttractionGroup AttractionInfo::get_attraction_group_info(const AttractGroupId group_id) {
39+
const AttractionGroup& AttractionInfo::get_attraction_group_info(const AttractGroupId group_id) {
4040
return attraction_groups[group_id];
4141
}
4242

vpr/src/pack/attraction_groups.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@
2020
*
2121
* Overview
2222
* ========
23-
* Attraction groups are used during the clustering process to tell the clusterer which atoms should be packed
24-
* in the same cluster by virtue of having the same floorplan constraints. The attraction groups may also be
25-
* used to cluster similar atoms together in other ways in the future.
23+
* Attraction groups are used during the clustering process. Atoms in the same attraction groups will be highly desirable to
24+
* be packed together. If an atom is in the same attraction group as an atoms already in the cluster, its gain will be increased
25+
* to reflect the increased desire to pack atoms of the same attraction group together. Currently, the attraction groups are created
26+
* based on which atoms are in the same Partition, from floorplanning constraints. In the future, attraction groups can be used to
27+
* pack atoms together based on other concepts.
2628
*/
2729

2830
/// @brief Type tag for AttractGroupId
2931
struct attraction_id_tag;
3032

31-
/// @brief A unique identifier for a partition
33+
/// @brief A unique identifier for an attraction group.
3234
typedef vtr::StrongId<attraction_id_tag> AttractGroupId;
3335

3436
struct AttractionGroup {
@@ -47,7 +49,7 @@ struct AttractionGroup {
4749
* into the same cluster
4850
*/
4951
/* TODO: Add the code in the clusterer that will do the above steps. */
50-
bool region_size_one = false;
52+
//bool must_be_packed_in_one_cluster = false;
5153
};
5254

5355
class AttractionInfo {
@@ -59,7 +61,7 @@ class AttractionInfo {
5961
//Setters and getters for the class
6062
AttractGroupId get_atom_attraction_group(const AtomBlockId atom_id);
6163

62-
AttractionGroup get_attraction_group_info(const AttractGroupId group_id);
64+
const AttractionGroup& get_attraction_group_info(const AttractGroupId group_id);
6365

6466
void set_atom_attraction_group(const AtomBlockId atom_id, const AttractGroupId group_id);
6567

@@ -75,6 +77,7 @@ class AttractionInfo {
7577

7678
private:
7779
//Store each atom's attraction group assuming each atom is in at most one attraction group
80+
//Atoms with no attraction group will have AttractGroupId::INVALID
7881
vtr::vector<AtomBlockId, AttractGroupId> atom_attraction_group;
7982

8083
//Store atoms and gain value that belong to each attraction group

vpr/src/pack/cluster.cpp

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -292,31 +292,31 @@ static t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
292292
int transitive_fanout_threshold,
293293
const int feasible_block_array_size);
294294

295-
void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
296-
t_cluster_placement_stats* cluster_placement_stats_ptr,
297-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
298-
const int feasible_block_array_size);
295+
static void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
296+
t_cluster_placement_stats* cluster_placement_stats_ptr,
297+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
298+
const int feasible_block_array_size);
299299

300-
void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
301-
t_cluster_placement_stats* cluster_placement_stats_ptr,
302-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
303-
const int feasible_block_array_size);
300+
static void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
301+
t_cluster_placement_stats* cluster_placement_stats_ptr,
302+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
303+
const int feasible_block_array_size);
304304

305-
void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
306-
t_cluster_placement_stats* cluster_placement_stats_ptr,
307-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
308-
AttractionInfo& attraction_groups,
309-
const int feasible_block_array_size);
310-
311-
void add_cluster_molecule_candidates_by_transitive_connectivity(t_pb* cur_pb,
305+
static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
312306
t_cluster_placement_stats* cluster_placement_stats_ptr,
313307
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
314-
vtr::vector<ClusterBlockId, std::vector<AtomNetId>>& clb_inter_blk_nets,
315-
const ClusterBlockId cluster_index,
316-
int transitive_fanout_threshold,
308+
AttractionInfo& attraction_groups,
317309
const int feasible_block_array_size);
318310

319-
bool check_free_primitives_for_molecule_atoms(t_pack_molecule* molecule, t_cluster_placement_stats* cluster_placement_stats_ptr);
311+
static void add_cluster_molecule_candidates_by_transitive_connectivity(t_pb* cur_pb,
312+
t_cluster_placement_stats* cluster_placement_stats_ptr,
313+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
314+
vtr::vector<ClusterBlockId, std::vector<AtomNetId>>& clb_inter_blk_nets,
315+
const ClusterBlockId cluster_index,
316+
int transitive_fanout_threshold,
317+
const int feasible_block_array_size);
318+
319+
static bool check_free_primitives_for_molecule_atoms(t_pack_molecule* molecule, t_cluster_placement_stats* cluster_placement_stats_ptr);
320320

321321
static t_pack_molecule* get_molecule_for_cluster(t_pb* cur_pb,
322322
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
@@ -2055,7 +2055,8 @@ static void mark_and_update_partial_gain(const AtomNetId net_id, enum e_gain_upd
20552055
/*****************************************/
20562056
static void update_total_gain(float alpha, float beta, bool timing_driven, bool connection_driven, t_pb* pb, AttractionInfo& attraction_groups) {
20572057
/*Updates the total gain array to reflect the desired tradeoff between*
2058-
*input sharing (sharinggain) and path_length minimization (timinggain)*/
2058+
*input sharing (sharinggain) and path_length minimization (timinggain)
2059+
*input each time a new molecule is added to the cluster.*/
20592060
auto& atom_ctx = g_vpr_ctx.atom();
20602061
t_pb* cur_pb = pb;
20612062

@@ -2126,8 +2127,10 @@ static void update_cluster_stats(const t_pack_molecule* molecule,
21262127
const int high_fanout_net_threshold,
21272128
const SetupTimingInfo& timing_info,
21282129
AttractionInfo& attraction_groups) {
2129-
/* Updates cluster stats such as gain, used pins, and clock structures. Also
2130-
* keeps track of which attraction group the cluster belongs to. */
2130+
/* Routine that is called each time a new molecule is added to the cluster.
2131+
* Makes calls to update cluster stats such as the gain map for atoms, used pins, and clock structures,
2132+
* in order to reflect the new content of the cluster.
2133+
* Also keeps track of which attraction group the cluster belongs to. */
21312134

21322135
int molecule_size;
21332136
int iblock;
@@ -2163,6 +2166,7 @@ static void update_cluster_stats(const t_pack_molecule* molecule,
21632166
cur_pb->pb_stats->num_child_blocks_in_pb++;
21642167

21652168
if (atom_grp_id != AttractGroupId::INVALID()) {
2169+
/* TODO: Allow clusters to have more than one attraction group. */
21662170
cur_pb->pb_stats->attraction_grp_id = atom_grp_id;
21672171
}
21682172

@@ -2465,10 +2469,10 @@ static t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
24652469
return molecule;
24662470
}
24672471

2468-
void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
2469-
t_cluster_placement_stats* cluster_placement_stats_ptr,
2470-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2471-
const int feasible_block_array_size) {
2472+
static void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
2473+
t_cluster_placement_stats* cluster_placement_stats_ptr,
2474+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2475+
const int feasible_block_array_size) {
24722476
VTR_ASSERT(cur_pb->pb_stats->num_feasible_blocks == NOT_VALID);
24732477

24742478
cur_pb->pb_stats->num_feasible_blocks = 0;
@@ -2493,10 +2497,10 @@ void add_cluster_molecule_candidates_by_connectivity_and_timing(t_pb* cur_pb,
24932497
}
24942498
}
24952499

2496-
void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
2497-
t_cluster_placement_stats* cluster_placement_stats_ptr,
2498-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2499-
const int feasible_block_array_size) {
2500+
static void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
2501+
t_cluster_placement_stats* cluster_placement_stats_ptr,
2502+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2503+
const int feasible_block_array_size) {
25002504
/* Because the packer ignores high fanout nets when marking what blocks
25012505
* to consider, use one of the ignored high fanout net to fill up lightly
25022506
* related blocks */
@@ -2532,11 +2536,11 @@ void add_cluster_molecule_candidates_by_highfanout_connectivity(t_pb* cur_pb,
25322536
cur_pb->pb_stats->tie_break_high_fanout_net = AtomNetId::INVALID(); /* Mark off that this high fanout net has been considered */
25332537
}
25342538

2535-
void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
2536-
t_cluster_placement_stats* cluster_placement_stats_ptr,
2537-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2538-
AttractionInfo& attraction_groups,
2539-
const int feasible_block_array_size) {
2539+
static void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
2540+
t_cluster_placement_stats* cluster_placement_stats_ptr,
2541+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2542+
AttractionInfo& attraction_groups,
2543+
const int feasible_block_array_size) {
25402544
auto& atom_ctx = g_vpr_ctx.atom();
25412545

25422546
//If the current cluster belongs to an attraction group, add all of the atoms
@@ -2563,13 +2567,13 @@ void add_cluster_molecule_candidates_by_attraction_group(t_pb* cur_pb,
25632567
}
25642568
}
25652569

2566-
void add_cluster_molecule_candidates_by_transitive_connectivity(t_pb* cur_pb,
2567-
t_cluster_placement_stats* cluster_placement_stats_ptr,
2568-
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2569-
vtr::vector<ClusterBlockId, std::vector<AtomNetId>>& clb_inter_blk_nets,
2570-
const ClusterBlockId cluster_index,
2571-
int transitive_fanout_threshold,
2572-
const int feasible_block_array_size) {
2570+
static void add_cluster_molecule_candidates_by_transitive_connectivity(t_pb* cur_pb,
2571+
t_cluster_placement_stats* cluster_placement_stats_ptr,
2572+
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
2573+
vtr::vector<ClusterBlockId, std::vector<AtomNetId>>& clb_inter_blk_nets,
2574+
const ClusterBlockId cluster_index,
2575+
int transitive_fanout_threshold,
2576+
const int feasible_block_array_size) {
25732577
//TODO: For now, only done by fan-out; should also consider fan-in
25742578

25752579
cur_pb->pb_stats->explore_transitive_fanout = false;
@@ -2593,7 +2597,7 @@ void add_cluster_molecule_candidates_by_transitive_connectivity(t_pb* cur_pb,
25932597
}
25942598
}
25952599

2596-
bool check_free_primitives_for_molecule_atoms(t_pack_molecule* molecule, t_cluster_placement_stats* cluster_placement_stats_ptr) {
2600+
static bool check_free_primitives_for_molecule_atoms(t_pack_molecule* molecule, t_cluster_placement_stats* cluster_placement_stats_ptr) {
25972601
auto& atom_ctx = g_vpr_ctx.atom();
25982602
bool success = true;
25992603

@@ -2603,7 +2607,7 @@ bool check_free_primitives_for_molecule_atoms(t_pack_molecule* molecule, t_clust
26032607
auto blk_id2 = molecule->atom_block_ids[i_atom];
26042608
if (!exists_free_primitive_for_atom_block(cluster_placement_stats_ptr, blk_id2)) {
26052609
/* TODO: debating whether to check if placement exists for molecule
2606-
* (more robust) or individual atom blocks (faster) */
2610+
* (more robust) or individual atom blocks (faster) (Jason Luu)*/
26072611
success = false;
26082612
break;
26092613
}

0 commit comments

Comments
 (0)