88 */
99
1010#include " appack_max_dist_th_manager.h"
11+ #include " appack_unrelated_clustering_manager.h"
1112#include " device_grid.h"
1213#include " flat_placement_types.h"
1314#include " physical_types.h"
@@ -68,43 +69,6 @@ struct t_appack_options {
6869 // Squared scaling factor for the quadratic decay term.
6970 static constexpr float quad_fac_sqr = (1 .0f - attenuation_th) / (dist_th * dist_th);
7071
71- // =========== Unrelated clustering ==================================== //
72- // After searching for candidates by connectivity and timing, the user may
73- // turn on unrelated clustering, which will allow molecules which are
74- // unrelated to the cluster being created to be attempted to be packed in.
75- // APPack uses flat placement information to decide which unrelated
76- // molecules to try.
77-
78- // APPack will search for unrelated molecules in the tile which contains
79- // the flat location of the cluster. It will then look farther out, tile
80- // by tile. This parameter is the maximum distance from the cluster's tile
81- // that APPack will search. Setting this to 0 would only allow APPack to
82- // search within the cluster's tile. Setting this to a higher number would
83- // allow APPack to search farther away; but may bring in molecules which
84- // do not "want" to be in the cluster.
85- //
86- // [block_type_index] -> unrelated_tile_distance
87- std::vector<float > max_unrelated_tile_distance;
88-
89- // Unrelated clustering occurs after all other candidate selection methods
90- // have failed. This attempts to cluster in molecules that are not attracted
91- // (using the packer's heuristics) to the molecules within a given cluster.
92- // This parameter sets how many times we will attempt unrelated
93- // clustering between failures of unrelated clustering. If a molecule used
94- // for unrelated clustering failed to cluster it will not be attempted
95- // again for that cluster (note: if it succeeds, the number of attempts get
96- // reset).
97- // NOTE: A similar option exists in the candidate selector class. This was
98- // duplicated since it is very likely that APPack would need a
99- // different value for this option than the non-APPack flow.
100- //
101- // [block_type_index] -> max_unrelated_attempts
102- std::vector<int > max_unrelated_clustering_attempts;
103- // By default, we perform 10 unrelated clustering attempts. This is used
104- // to aggresivly resolve density while adhering to the GP solution as much
105- // as possible.
106- static constexpr int default_max_unrelated_clustering_attempts = 10 ;
107-
10872 // TODO: Investigate adding flat placement info to seed selection.
10973};
11074
@@ -126,22 +90,16 @@ struct APPackContext : public Context {
12690 , flat_placement_info(fplace_info) {
12791
12892 // If the flat placement info has been provided, calculate max distance
129- // thresholds for all logical block types.
93+ // thresholds for all logical block types and the unrelated clustering
94+ // arguments.
13095 if (fplace_info.valid ) {
13196 max_distance_threshold_manager.init (ap_opts.appack_max_dist_th ,
13297 logical_block_types,
13398 device_grid);
134- }
13599
136- // Set the max unrelated tile distances for all logical block types.
137- // By default, we set this to a low value to only allow unrelated molecules
138- // that are very close to the cluster being created.
139- // NOTE: Molecules within the same tile as the centroid are considered to have
140- // 0 distance. The distance is computed relative to the bounds of the
141- // tile containing the centroid.
142- appack_options.max_unrelated_tile_distance .resize (logical_block_types.size (), 1.0 );
143- appack_options.max_unrelated_clustering_attempts .resize (logical_block_types.size (),
144- appack_options.default_max_unrelated_clustering_attempts );
100+ unrelated_clustering_manager.init (ap_opts.appack_unrelated_clustering_args ,
101+ logical_block_types);
102+ }
145103 }
146104
147105 /* *
@@ -157,4 +115,9 @@ struct APPackContext : public Context {
157115 // When selecting candidates, what distance from the cluster will we
158116 // consider? Any candidate beyond this distance will not be proposed.
159117 APPackMaxDistThManager max_distance_threshold_manager;
118+
119+ // When performing unrelated clustering, the following manager class decides
120+ // how far we should search for unrelated candidates and how many attempts
121+ // we should perform.
122+ APPackUnrelatedClusteringManager unrelated_clustering_manager;
160123};
0 commit comments