@@ -69,6 +69,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
69
69
const t_analysis_opts& analysis_opts,
70
70
const t_arch* arch,
71
71
Prepacker& prepacker,
72
+ ClusterLegalizer& cluster_legalizer,
72
73
const std::unordered_set<AtomNetId>& is_clock,
73
74
const std::unordered_set<AtomNetId>& is_global,
74
75
bool allow_unrelated_clustering,
@@ -120,7 +121,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
120
121
121
122
auto & atom_ctx = g_vpr_ctx.atom ();
122
123
auto & device_ctx = g_vpr_ctx.mutable_device ();
123
- auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
124
124
125
125
std::shared_ptr<PreClusterDelayCalculator> clustering_delay_calc;
126
126
std::shared_ptr<SetupTimingInfo> timing_info;
@@ -151,7 +151,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
151
151
cluster_stats.num_molecules = prepacker.get_num_molecules ();
152
152
153
153
if (packer_opts.hill_climbing_flag ) {
154
- size_t max_cluster_size = helper_ctx. cluster_legalizer .get_max_cluster_size ();
154
+ size_t max_cluster_size = cluster_legalizer.get_max_cluster_size ();
155
155
clustering_data.hill_climbing_inputs_avail = new int [max_cluster_size + 1 ];
156
156
for (size_t i = 0 ; i < max_cluster_size + 1 ; i++)
157
157
clustering_data.hill_climbing_inputs_avail [i] = 0 ;
@@ -190,7 +190,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
190
190
191
191
/* index of next most timing critical block */
192
192
int seed_index = 0 ;
193
- istart = get_highest_gain_seed_molecule (seed_index, seed_atoms);
193
+ istart = get_highest_gain_seed_molecule (seed_index, seed_atoms, cluster_legalizer );
194
194
195
195
print_pack_status_header ();
196
196
@@ -214,14 +214,13 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
214
214
if (is_cluster_legal)
215
215
break ;
216
216
// Set the legalization strategy of the cluster legalizer.
217
- // FIXME: Pass in the cluster legalizer.
218
- helper_ctx.cluster_legalizer .set_legalization_strategy (strategy);
217
+ cluster_legalizer.set_legalization_strategy (strategy);
219
218
220
219
LegalizationClusterId legalization_cluster_id;
221
220
222
221
VTR_LOGV (verbosity > 2 , " Complex block %d:\n " , total_clb_num);
223
222
224
- start_new_cluster (helper_ctx. cluster_legalizer ,
223
+ start_new_cluster (cluster_legalizer,
225
224
legalization_cluster_id,
226
225
istart,
227
226
num_used_type_instances,
@@ -240,18 +239,20 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
240
239
cluster_stats.mols_since_last_print ,
241
240
device_ctx.grid .width (),
242
241
device_ctx.grid .height (),
243
- attraction_groups);
242
+ attraction_groups,
243
+ cluster_legalizer);
244
244
245
245
VTR_LOGV (verbosity > 2 ,
246
246
" Complex block %d: '%s' (%s) " , total_clb_num,
247
- helper_ctx. cluster_legalizer .get_cluster_pb (legalization_cluster_id)->name ,
248
- helper_ctx. cluster_legalizer .get_cluster_type (legalization_cluster_id)->name );
247
+ cluster_legalizer.get_cluster_pb (legalization_cluster_id)->name ,
248
+ cluster_legalizer.get_cluster_type (legalization_cluster_id)->name );
249
249
VTR_LOGV (verbosity > 2 , " ." );
250
250
// Progress dot for seed-block
251
251
fflush (stdout);
252
252
253
- int high_fanout_threshold = high_fanout_thresholds.get_threshold (helper_ctx. cluster_legalizer .get_cluster_type (legalization_cluster_id)->name );
253
+ int high_fanout_threshold = high_fanout_thresholds.get_threshold (cluster_legalizer.get_cluster_type (legalization_cluster_id)->name );
254
254
update_cluster_stats (istart,
255
+ cluster_legalizer,
255
256
is_clock, // Set of clock nets
256
257
is_global, // Set of global nets (currently all clocks)
257
258
packer_opts.global_clocks ,
@@ -268,17 +269,17 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
268
269
/* it doesn't make sense to do a timing analysis here since there*
269
270
*is only one atom block clustered it would not change anything */
270
271
}
271
- // FIXME: This access should be a getter.
272
- cur_cluster_placement_stats_ptr = &(helper_ctx.cluster_legalizer .cluster_placement_stats [helper_ctx.cluster_legalizer .get_cluster_type (legalization_cluster_id)->index ]);
272
+ cur_cluster_placement_stats_ptr = cluster_legalizer.get_cluster_placement_stats (legalization_cluster_id);
273
273
cluster_stats.num_unrelated_clustering_attempts = 0 ;
274
- next_molecule = get_molecule_for_cluster (helper_ctx. cluster_legalizer .get_cluster_pb (legalization_cluster_id),
274
+ next_molecule = get_molecule_for_cluster (cluster_legalizer.get_cluster_pb (legalization_cluster_id),
275
275
attraction_groups,
276
276
allow_unrelated_clustering,
277
277
packer_opts.prioritize_transitive_connectivity ,
278
278
packer_opts.transitive_fanout_threshold ,
279
279
packer_opts.feasible_block_array_size ,
280
280
&cluster_stats.num_unrelated_clustering_attempts ,
281
281
cur_cluster_placement_stats_ptr,
282
+ cluster_legalizer,
282
283
clb_inter_blk_nets,
283
284
legalization_cluster_id,
284
285
verbosity,
@@ -306,7 +307,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
306
307
while (next_molecule != nullptr && num_repeated_molecules < max_num_repeated_molecules) {
307
308
prev_molecule = next_molecule;
308
309
309
- try_fill_cluster (helper_ctx. cluster_legalizer ,
310
+ try_fill_cluster (cluster_legalizer,
310
311
packer_opts,
311
312
cur_cluster_placement_stats_ptr,
312
313
prev_molecule,
@@ -337,15 +338,14 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
337
338
// If the legalizer did not check everything for every molecule,
338
339
// need to check that the full cluster is legal (need to perform
339
340
// intra-lb routing).
340
- is_cluster_legal = helper_ctx. cluster_legalizer .check_cluster_legality (legalization_cluster_id);
341
+ is_cluster_legal = cluster_legalizer.check_cluster_legality (legalization_cluster_id);
341
342
}
342
343
343
344
if (is_cluster_legal) {
344
- // helper_ctx.legalized_clusters.push_back(legalization_cluster_id);
345
- istart = save_cluster_routing_and_pick_new_seed (packer_opts, seed_atoms, num_blocks_hill_added, seed_index, cluster_stats);
346
- store_cluster_info_and_free (packer_opts, legalization_cluster_id, logic_block_type, le_pb_type, le_count, clb_inter_blk_nets);
345
+ istart = save_cluster_routing_and_pick_new_seed (packer_opts, seed_atoms, cluster_legalizer, num_blocks_hill_added, seed_index, cluster_stats);
346
+ store_cluster_info_and_free (packer_opts, legalization_cluster_id, logic_block_type, le_pb_type, le_count, cluster_legalizer, clb_inter_blk_nets);
347
347
} else {
348
- free_data_and_requeue_used_mols_if_illegal (legalization_cluster_id, saved_seed_index, num_used_type_instances, total_clb_num, seed_index);
348
+ free_data_and_requeue_used_mols_if_illegal (legalization_cluster_id, cluster_legalizer, saved_seed_index, num_used_type_instances, total_clb_num, seed_index);
349
349
}
350
350
}
351
351
}
@@ -361,7 +361,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
361
361
// Ensure that we have kept track of the number of clusters correctly.
362
362
// TODO: The total_clb_num variable could probably just be replaced by
363
363
// clusters().size().
364
- VTR_ASSERT (helper_ctx. cluster_legalizer .clusters ().size () == (size_t )total_clb_num);
364
+ VTR_ASSERT (cluster_legalizer.clusters ().size () == (size_t )total_clb_num);
365
365
366
366
return num_used_type_instances;
367
367
}
0 commit comments