@@ -39,16 +39,15 @@ struct ClusterGainStats {
3939 // / @brief Attraction (inverse of cost) function.
4040 std::unordered_map<AtomBlockId, float > gain;
4141
42- // / @brief The timing criticality score of this atom cluster_ctx.blocks .
42+ // / @brief The timing criticality score of this atom.
4343 // / Determined by the most critical atom net between this atom
44- // / cluster_ctx.blocks and any atom cluster_ctx.blocks in the current
45- // / pb.
46- std::unordered_map<AtomBlockId, float > timinggain;
44+ // / and any atom in the current pb.
45+ std::unordered_map<AtomBlockId, float > timing_gain;
4746 // / @brief Weighted sum of connections to attraction function.
48- std::unordered_map<AtomBlockId, float > connectiongain ;
49- // / @brief How many nets on an atom cluster_ctx.blocks are already in the
50- // / pb under consideration.
51- std::unordered_map<AtomBlockId, float > sharinggain ;
47+ std::unordered_map<AtomBlockId, float > connection_gain ;
48+ // / @brief How many nets on an atom are already in the pb under
49+ // / consideration.
50+ std::unordered_map<AtomBlockId, float > sharing_gain ;
5251
5352 // / @brief Stores the number of times atoms have failed to be packed into
5453 // / the cluster.
@@ -57,7 +56,9 @@ struct ClusterGainStats {
5756 // / has failed to be packed into the cluster.
5857 std::unordered_map<AtomBlockId, int > atom_failures;
5958
60- // / @brief List of nets with the num_pins_of_net_in_pb and gain entries altered.
59+ // / @brief List of nets with the num_pins_of_net_in_pb and gain entries
60+ // / altered (i.e. have some gain-related connection to the current
61+ // / cluster).
6162 std::vector<AtomNetId> marked_nets;
6263 // / @brief List of blocks with the num_pins_of_net_in_pb and gain entries altered.
6364 std::vector<AtomBlockId> marked_blocks;
@@ -69,7 +70,7 @@ struct ClusterGainStats {
6970 // / determine next candidate molecule then explore molecules on
7071 // / transitive fanout.
7172 bool explore_transitive_fanout;
72- // / @brief Holding trasitive fanout candidates key: root block id of the
73+ // / @brief Holding transitive fanout candidates key: root block id of the
7374 // / molecule, value: pointer to the molecule.
7475 // TODO: This should be an unordered map, unless stability is desired.
7576 std::map<AtomBlockId, t_pack_molecule*> transitive_fanout_candidates;
@@ -87,7 +88,7 @@ struct ClusterGainStats {
8788 // / Sorted in ascending gain order so that the last cluster_ctx.blocks is
8889 // / the most desirable (this makes it easy to pop blocks off the list.
8990 std::vector<t_pack_molecule*> feasible_blocks;
90- int num_feasible_blocks; /* [0..num_marked_models-1] */
91+ int num_feasible_blocks;
9192};
9293
9394/* *
@@ -139,10 +140,16 @@ class GreedyCandidateSelector {
139140 static constexpr int AAPACK_MAX_HIGH_FANOUT_EXPLORE = 10 ;
140141
141142 // / @brief When investigating transitive fanout connections in packing,
142- // / consider a maximum of this many molecule s , must be less than
143+ // / consider a maximum of this many molecules , must be less than
143144 // / packer_opts.feasible_block_array_size.
144145 static constexpr int AAPACK_MAX_TRANSITIVE_EXPLORE = 40 ;
145146
147+ // / @brief When adding cluster molecule candidates by attraction groups,
148+ // / only investigate this many candidates. Some attraction groups can
149+ // / get very large; so this threshold decides when to explore all
150+ // / atoms in the group, or a randomly selected number of them.
151+ static constexpr int attraction_group_num_atoms_threshold_ = 500 ;
152+
146153public:
147154 ~GreedyCandidateSelector ();
148155
@@ -181,9 +188,9 @@ class GreedyCandidateSelector {
181188 * @param net_output_feeds_driving_block_input
182189 * The set of nets whose output feeds the block that drives
183190 * itself. This may cause double-counting in the gain
184- * calculations and need to be handled special.
191+ * calculations and needs special handling .
185192 * @param timing_info
186- * Setup timing info for this Atom Netlist. Used to incorperate
193+ * Setup timing info for this Atom Netlist. Used to incorporate
187194 * timing / criticality into the gain calculation.
188195 * @param log_verbosity
189196 * The verbosity of log messages in the candidate selector.
@@ -265,8 +272,6 @@ class GreedyCandidateSelector {
265272 * @param failed_mol
266273 * The molecule that failed to pack into the cluster.
267274 */
268- // Update the cluster gain stats after a candidate was unsuccessfully
269- // clustered into the current cluster.
270275 void update_cluster_gain_stats_candidate_failed (
271276 ClusterGainStats& cluster_gain_stats,
272277 t_pack_molecule* failed_mol);
@@ -304,7 +309,9 @@ class GreedyCandidateSelector {
304309 * This should be called after all molecules have been packed into a cluster.
305310 *
306311 * This updates internal lookup tables in the candidate selector. For
307- * example, inter-clb nets.
312+ * example, what inter-clb nets exist on a cluster are stored by this
313+ * routine to make later transistive gain function calculations more
314+ * efficient.
308315 *
309316 * @param cluster_gain_stats
310317 * The cluster gain stats for the cluster to finalize.
@@ -351,7 +358,7 @@ class GreedyCandidateSelector {
351358 e_net_relation_to_clustered_block net_relation_to_clustered_block);
352359
353360 /* *
354- * @brief Updates the connectiongain in the cluster_gain_stats.
361+ * @brief Updates the connection_gain in the cluster_gain_stats.
355362 */
356363 void update_connection_gain_values (ClusterGainStats& cluster_gain_stats,
357364 AtomNetId net_id,
@@ -360,7 +367,7 @@ class GreedyCandidateSelector {
360367 e_net_relation_to_clustered_block net_relation_to_clustered_block);
361368
362369 /* *
363- * Updates the timinggain in the cluster_gain_stats.
370+ * Updates the timing_gain in the cluster_gain_stats.
364371 */
365372 void update_timing_gain_values (ClusterGainStats& cluster_gain_stats,
366373 AtomNetId net_id,
@@ -369,8 +376,8 @@ class GreedyCandidateSelector {
369376
370377 /* *
371378 * @brief Updates the total gain array to reflect the desired tradeoff
372- * between input sharing (sharinggain ) and path_length minimization
373- * (timinggain ) input each time a new molecule is added to the
379+ * between input sharing (sharing_gain ) and path_length minimization
380+ * (timing_gain ) input each time a new molecule is added to the
374381 * cluster.
375382 */
376383 void update_total_gain (ClusterGainStats& cluster_gain_stats,
@@ -439,8 +446,8 @@ class GreedyCandidateSelector {
439446 *
440447 * Attraction groups can be very large, so we only add some randomly
441448 * selected molecules for efficiency if the number of atoms in the group is
442- * greater than 500 . Therefore, the molecules added to the candidates will
443- * vary each time you call this function.
449+ * greater than some threshold . Therefore, the molecules added to the
450+ * candidates will vary each time you call this function.
444451 */
445452 void add_cluster_molecule_candidates_by_attraction_group (
446453 ClusterGainStats& cluster_gain_stats,
@@ -450,7 +457,7 @@ class GreedyCandidateSelector {
450457 AttractionInfo& attraction_groups);
451458
452459 /* *
453- * @brief Finds a molecule to propose which is unrelated by may be good to
460+ * @brief Finds a molecule to propose which is unrelated but may be good to
454461 * cluster.
455462 */
456463 t_pack_molecule* get_unrelated_candidate_for_cluster (
@@ -473,7 +480,8 @@ class GreedyCandidateSelector {
473480 // / @brief The verbosity of log messages in the candidate selector.
474481 const int log_verbosity_;
475482
476- // / @brief Pre-computed logical block types for each model in the architecture.
483+ // / @brief Pre-computed vector of logical block types that could implement
484+ // / the given model in the architecture.
477485 const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types_;
478486
479487 // / @brief The high-fanout thresholds per logical block type. Used to ignore
@@ -500,7 +508,9 @@ class GreedyCandidateSelector {
500508 // / transitive candidates.
501509 vtr::vector<LegalizationClusterId, std::vector<AtomNetId>> clb_inter_blk_nets_;
502510
503- // / @brief Data pre-computed to help select unrelated molecules.
511+ // / @brief Data pre-computed to help select unrelated molecules. This is a
512+ // / list of list of molecules sorted by their gain, where the first
513+ // / dimension is the number of external outputs of the molecule.
504514 std::vector<std::vector<t_pack_molecule *>> unrelated_clustering_data_;
505515
506516 // / @brief A count on the number of unrelated clustering attempts which
0 commit comments