@@ -24,15 +24,88 @@ CentroidMoveGenerator::CentroidMoveGenerator(float noc_attraction_weight, size_t
2424 , noc_attraction_enabled_(true ) {
2525 VTR_ASSERT (noc_attraction_weight > 0.0 && noc_attraction_weight <= 1.0 );
2626
27- const auto & cluster_ctx = g_vpr_ctx.clustering ();
28- const auto & noc_ctx = g_vpr_ctx.noc ();
2927
3028 // check if static member variables are already initialized
3129 if (!noc_group_clusters_.empty () && !noc_group_routers_.empty () &&
3230 !cluster_to_noc_grp_.empty () && !noc_router_to_noc_group_.empty ()) {
3331 return ;
32+ } else {
33+ initialize_noc_groups (high_fanout_net);
34+ }
35+ }
36+
37+ e_create_move CentroidMoveGenerator::propose_move (t_pl_blocks_to_be_moved& blocks_affected,
38+ t_propose_action& proposed_action,
39+ float rlim,
40+ const t_placer_opts& placer_opts,
41+ const PlacerCriticalities* /* criticalities*/ ) {
42+ // Find a movable block based on blk_type
43+ ClusterBlockId b_from = propose_block_to_move (placer_opts,
44+ proposed_action.logical_blk_type_index ,
45+ false ,
46+ nullptr ,
47+ nullptr );
48+
49+ VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug ,
50+ " Centroid Move Choose Block %d - rlim %f\n " ,
51+ size_t (b_from),
52+ rlim);
53+
54+ if (!b_from) { // No movable block found
55+ VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug ,
56+ " \t No movable block found\n " );
57+ return e_create_move::ABORT;
3458 }
3559
60+ const auto & device_ctx = g_vpr_ctx.device ();
61+ const auto & place_ctx = g_vpr_ctx.placement ();
62+ const auto & cluster_ctx = g_vpr_ctx.clustering ();
63+ auto & place_move_ctx = g_placer_ctx.mutable_move ();
64+
65+ t_pl_loc from = place_ctx.block_locs [b_from].loc ;
66+ auto cluster_from_type = cluster_ctx.clb_nlist .block_type (b_from);
67+ auto grid_from_type = device_ctx.grid .get_physical_type ({from.x , from.y , from.layer });
68+ VTR_ASSERT (is_tile_compatible (grid_from_type, cluster_from_type));
69+
70+ t_range_limiters range_limiters{rlim,
71+ place_move_ctx.first_rlim ,
72+ placer_opts.place_dm_rlim };
73+
74+ t_pl_loc to, centroid;
75+
76+ /* Calculate the centroid location*/
77+ calculate_centroid_loc (b_from, false , centroid, nullptr , noc_attraction_enabled_, noc_attraction_w_);
78+
79+ // Centroid location is not necessarily a valid location, and the downstream location expect a valid
80+ // layer for "to" location. So if the layer is not valid, we set it to the same layer as from loc.
81+ to.layer = (centroid.layer < 0 ) ? from.layer : centroid.layer ;
82+ /* Find a location near the weighted centroid_loc */
83+ if (!find_to_loc_centroid (cluster_from_type, from, centroid, range_limiters, to, b_from)) {
84+ return e_create_move::ABORT;
85+ }
86+
87+ e_create_move create_move = ::create_move (blocks_affected, b_from, to);
88+
89+ // Check that all the blocks affected by the move would still be in a legal floorplan region after the swap
90+ if (!floorplan_legal (blocks_affected)) {
91+ return e_create_move::ABORT;
92+ }
93+
94+ return create_move;
95+ }
96+
97+ const std::vector<ClusterBlockId>& CentroidMoveGenerator::get_noc_group_routers (NocGroupId noc_grp_id) {
98+ return CentroidMoveGenerator::noc_group_routers_[noc_grp_id];
99+ }
100+
101+ NocGroupId CentroidMoveGenerator::get_cluster_noc_group (ClusterBlockId blk_id) {
102+ return CentroidMoveGenerator::cluster_to_noc_grp_[blk_id];
103+ }
104+
105+ void CentroidMoveGenerator::initialize_noc_groups (size_t high_fanout_net) {
106+ const auto & cluster_ctx = g_vpr_ctx.clustering ();
107+ const auto & noc_ctx = g_vpr_ctx.noc ();
108+
36109 noc_group_clusters_.clear ();
37110 noc_group_routers_.clear ();
38111 cluster_to_noc_grp_.clear ();
@@ -127,71 +200,3 @@ CentroidMoveGenerator::CentroidMoveGenerator(float noc_attraction_weight, size_t
127200 }
128201 }
129202}
130-
131- e_create_move CentroidMoveGenerator::propose_move (t_pl_blocks_to_be_moved& blocks_affected,
132- t_propose_action& proposed_action,
133- float rlim,
134- const t_placer_opts& placer_opts,
135- const PlacerCriticalities* /* criticalities*/ ) {
136- // Find a movable block based on blk_type
137- ClusterBlockId b_from = propose_block_to_move (placer_opts,
138- proposed_action.logical_blk_type_index ,
139- false ,
140- nullptr ,
141- nullptr );
142-
143- VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug ,
144- " Centroid Move Choose Block %d - rlim %f\n " ,
145- size_t (b_from),
146- rlim);
147-
148- if (!b_from) { // No movable block found
149- VTR_LOGV_DEBUG (g_vpr_ctx.placement ().f_placer_debug ,
150- " \t No movable block found\n " );
151- return e_create_move::ABORT;
152- }
153-
154- const auto & device_ctx = g_vpr_ctx.device ();
155- const auto & place_ctx = g_vpr_ctx.placement ();
156- const auto & cluster_ctx = g_vpr_ctx.clustering ();
157- auto & place_move_ctx = g_placer_ctx.mutable_move ();
158-
159- t_pl_loc from = place_ctx.block_locs [b_from].loc ;
160- auto cluster_from_type = cluster_ctx.clb_nlist .block_type (b_from);
161- auto grid_from_type = device_ctx.grid .get_physical_type ({from.x , from.y , from.layer });
162- VTR_ASSERT (is_tile_compatible (grid_from_type, cluster_from_type));
163-
164- t_range_limiters range_limiters{rlim,
165- place_move_ctx.first_rlim ,
166- placer_opts.place_dm_rlim };
167-
168- t_pl_loc to, centroid;
169-
170- /* Calculate the centroid location*/
171- calculate_centroid_loc (b_from, false , centroid, nullptr , noc_attraction_enabled_, noc_attraction_w_);
172-
173- // Centroid location is not necessarily a valid location, and the downstream location expect a valid
174- // layer for "to" location. So if the layer is not valid, we set it to the same layer as from loc.
175- to.layer = (centroid.layer < 0 ) ? from.layer : centroid.layer ;
176- /* Find a location near the weighted centroid_loc */
177- if (!find_to_loc_centroid (cluster_from_type, from, centroid, range_limiters, to, b_from)) {
178- return e_create_move::ABORT;
179- }
180-
181- e_create_move create_move = ::create_move (blocks_affected, b_from, to);
182-
183- // Check that all the blocks affected by the move would still be in a legal floorplan region after the swap
184- if (!floorplan_legal (blocks_affected)) {
185- return e_create_move::ABORT;
186- }
187-
188- return create_move;
189- }
190-
191- const std::vector<ClusterBlockId>& CentroidMoveGenerator::get_noc_group_routers (NocGroupId noc_grp_id) {
192- return CentroidMoveGenerator::noc_group_routers_[noc_grp_id];
193- }
194-
195- NocGroupId CentroidMoveGenerator::get_cluster_noc_group (ClusterBlockId blk_id) {
196- return CentroidMoveGenerator::cluster_to_noc_grp_[blk_id];
197- }
0 commit comments