@@ -169,7 +169,7 @@ static void print_pack_status(int num_clb,
169
169
int device_height,
170
170
AttractionInfo& attraction_groups);
171
171
172
- static void update_attraction_group_status (AttractionInfo& attraction_groups);
172
+ static void rebuild_attraction_groups (AttractionInfo& attraction_groups);
173
173
174
174
static void record_molecule_failure (t_pack_molecule* molecule, t_pb* pb);
175
175
@@ -443,6 +443,12 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
443
443
*
444
444
*/
445
445
446
+ /* This routine returns a map that details the number of used block type instances.
447
+ * The bool floorplan_regions_overfull also acts as a return value - it is set to
448
+ * true when one or more floorplan regions have more blocks assigned to them than
449
+ * they can fit.
450
+ */
451
+
446
452
/* ***************************************************************
447
453
* Initialization
448
454
*****************************************************************/
@@ -638,6 +644,14 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
638
644
primitive_candidate_block_types);
639
645
prev_molecule = istart;
640
646
647
+ /*
648
+ * When attraction groups are created, the purpose is to pack more densely by adding more molecules
649
+ * from the cluster's attraction group to the cluster. In a normal flow, (when attraction groups are
650
+ * not on), the cluster keeps being packed until the get_molecule routines return either a repeated
651
+ * molecule or a nullptr. When attraction groups are on, we want to keep exploring molecules for the
652
+ * cluster until a nullptr is returned. So, the number of repeated molecules allowed is increased to a
653
+ * large value.
654
+ */
641
655
int max_num_repeated_molecules = 0 ;
642
656
if (attraction_groups.num_attraction_groups () > 0 ) {
643
657
max_num_repeated_molecules = ATTRACTION_GROUPS_MAX_REPEATED_MOLECULES;
@@ -719,6 +733,7 @@ static void print_pack_status(int num_clb,
719
733
int device_width,
720
734
int device_height,
721
735
AttractionInfo& attraction_groups) {
736
+ // Print a packing update each time another 4% of molecules have been packed.
722
737
const float print_frequency = 0.04 ;
723
738
724
739
double percentage = (num_molecules_processed / (double )tot_num_molecules) * 100 ;
@@ -743,17 +758,17 @@ static void print_pack_status(int num_clb,
743
758
fflush (stdout);
744
759
mols_since_last_print = 0 ;
745
760
if (attraction_groups.num_attraction_groups () > 0 ) {
746
- update_attraction_group_status (attraction_groups);
761
+ rebuild_attraction_groups (attraction_groups);
747
762
}
748
763
}
749
764
}
750
765
751
766
/*
752
- * Periodically update the attraction groups to reflect which atoms in them
767
+ * Periodically rebuild the attraction groups to reflect which atoms in them
753
768
* are still available for new clusters (i.e. remove the atoms that have already
754
769
* been packed from the attraction group).
755
770
*/
756
- static void update_attraction_group_status (AttractionInfo& attraction_groups) {
771
+ static void rebuild_attraction_groups (AttractionInfo& attraction_groups) {
757
772
auto & atom_ctx = g_vpr_ctx.atom ();
758
773
759
774
for (int igroup = 0 ; igroup < attraction_groups.num_attraction_groups (); igroup++) {
@@ -762,6 +777,7 @@ static void update_attraction_group_status(AttractionInfo& attraction_groups) {
762
777
AttractionGroup new_att_group_info;
763
778
764
779
for (AtomBlockId atom : group.group_atoms ) {
780
+ // If the ClusterBlockId is anything other than invalid, the atom has been packed already
765
781
if (atom_ctx.lookup .atom_clb (atom) == ClusterBlockId::INVALID ()) {
766
782
new_att_group_info.group_atoms .push_back (atom);
767
783
}
@@ -785,6 +801,9 @@ static bool is_atom_blk_in_pb(const AtomBlockId blk_id, const t_pb* pb) {
785
801
return false ;
786
802
}
787
803
804
+ /* Remove blk from list of feasible blocks sorted according to gain
805
+ * Useful for removing blocks that are repeatedly failing. If a block
806
+ * has been found to be illegal, we don't repeatedly consider it.*/
788
807
static void remove_molecule_from_pb_stats_candidates (t_pack_molecule* molecule,
789
808
t_pb* pb) {
790
809
int molecule_index;
@@ -1528,16 +1547,21 @@ static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* clu
1528
1547
return block_pack_status;
1529
1548
}
1530
1549
1550
+ /* Record the failure of the molecule in this cluster in the current pb stats.
1551
+ * If a molecule fails repeatedly, it's gain will be penalized if packing with
1552
+ * attraction groups on. */
1531
1553
static void record_molecule_failure (t_pack_molecule* molecule, t_pb* pb) {
1532
- // Record the failure of the molecule in this cluster in the current pb stats
1533
- for (unsigned int i_atom = 0 ; i_atom < molecule->atom_block_ids .size (); i_atom++) {
1534
- auto got = pb->pb_stats ->atom_failures .find (molecule->atom_block_ids [i_atom]);
1535
- if (got == pb->pb_stats ->atom_failures .end ()) {
1536
- pb->pb_stats ->atom_failures .insert ({molecule->atom_block_ids [i_atom], 1 });
1537
- } else {
1538
- got->second ++;
1539
- }
1540
- }
1554
+ // Only have to record the failure for the first atom in the molecule.
1555
+ // The convention when checking if a molecule has failed to pack in the cluster
1556
+ // is to check whether the first atoms has been recorded as having failed
1557
+
1558
+ auto got = pb->pb_stats ->atom_failures .find (molecule->atom_block_ids [0 ]);
1559
+ if (got == pb->pb_stats ->atom_failures .end ()) {
1560
+ pb->pb_stats ->atom_failures .insert ({molecule->atom_block_ids [0 ], 1 });
1561
+ } else {
1562
+ got->second ++;
1563
+ }
1564
+
1541
1565
}
1542
1566
1543
1567
/* *
0 commit comments