Skip to content

Commit 2e4c4ca

Browse files
[SQUASH ME] Removed the legalizer from the global scope
1 parent b56a127 commit 2e4c4ca

11 files changed

+317
-320
lines changed

vpr/src/base/vpr_context.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <vector>
66
#include <mutex>
77

8-
#include "cluster_legalizer.h"
98
#include "prepack.h"
109
#include "vpr_types.h"
1110
#include "vtr_ndmatrix.h"
@@ -316,10 +315,6 @@ struct ClusteringContext : public Context {
316315
* in packing or placement stages.
317316
*/
318317
struct ClusteringHelperContext : public Context {
319-
/// @brief Class used to construct legal clusters.
320-
/// FIXME: Move this to the cluster context?
321-
ClusterLegalizer cluster_legalizer;
322-
323318
// A vector of routing resource nodes within each of logic cluster_ctx.blocks types [0 .. num_logical_block_type-1]
324319
// FIXME: This is only used for a handoff between the vpr_setup and the packer.
325320
// This can be made cleaner.

vpr/src/pack/cluster.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
6969
const t_analysis_opts& analysis_opts,
7070
const t_arch* arch,
7171
Prepacker& prepacker,
72+
ClusterLegalizer& cluster_legalizer,
7273
const std::unordered_set<AtomNetId>& is_clock,
7374
const std::unordered_set<AtomNetId>& is_global,
7475
bool allow_unrelated_clustering,
@@ -120,7 +121,6 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
120121

121122
auto& atom_ctx = g_vpr_ctx.atom();
122123
auto& device_ctx = g_vpr_ctx.mutable_device();
123-
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
124124

125125
std::shared_ptr<PreClusterDelayCalculator> clustering_delay_calc;
126126
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
151151
cluster_stats.num_molecules = prepacker.get_num_molecules();
152152

153153
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();
155155
clustering_data.hill_climbing_inputs_avail = new int[max_cluster_size + 1];
156156
for (size_t i = 0; i < max_cluster_size + 1; i++)
157157
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
190190

191191
/* index of next most timing critical block */
192192
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);
194194

195195
print_pack_status_header();
196196

@@ -214,14 +214,13 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
214214
if (is_cluster_legal)
215215
break;
216216
// 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);
219218

220219
LegalizationClusterId legalization_cluster_id;
221220

222221
VTR_LOGV(verbosity > 2, "Complex block %d:\n", total_clb_num);
223222

224-
start_new_cluster(helper_ctx.cluster_legalizer,
223+
start_new_cluster(cluster_legalizer,
225224
legalization_cluster_id,
226225
istart,
227226
num_used_type_instances,
@@ -240,18 +239,20 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
240239
cluster_stats.mols_since_last_print,
241240
device_ctx.grid.width(),
242241
device_ctx.grid.height(),
243-
attraction_groups);
242+
attraction_groups,
243+
cluster_legalizer);
244244

245245
VTR_LOGV(verbosity > 2,
246246
"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);
249249
VTR_LOGV(verbosity > 2, ".");
250250
//Progress dot for seed-block
251251
fflush(stdout);
252252

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);
254254
update_cluster_stats(istart,
255+
cluster_legalizer,
255256
is_clock, //Set of clock nets
256257
is_global, //Set of global nets (currently all clocks)
257258
packer_opts.global_clocks,
@@ -268,17 +269,17 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
268269
/*it doesn't make sense to do a timing analysis here since there*
269270
*is only one atom block clustered it would not change anything */
270271
}
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);
273273
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),
275275
attraction_groups,
276276
allow_unrelated_clustering,
277277
packer_opts.prioritize_transitive_connectivity,
278278
packer_opts.transitive_fanout_threshold,
279279
packer_opts.feasible_block_array_size,
280280
&cluster_stats.num_unrelated_clustering_attempts,
281281
cur_cluster_placement_stats_ptr,
282+
cluster_legalizer,
282283
clb_inter_blk_nets,
283284
legalization_cluster_id,
284285
verbosity,
@@ -306,7 +307,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
306307
while (next_molecule != nullptr && num_repeated_molecules < max_num_repeated_molecules) {
307308
prev_molecule = next_molecule;
308309

309-
try_fill_cluster(helper_ctx.cluster_legalizer,
310+
try_fill_cluster(cluster_legalizer,
310311
packer_opts,
311312
cur_cluster_placement_stats_ptr,
312313
prev_molecule,
@@ -337,15 +338,14 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
337338
// If the legalizer did not check everything for every molecule,
338339
// need to check that the full cluster is legal (need to perform
339340
// 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);
341342
}
342343

343344
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);
347347
} 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);
349349
}
350350
}
351351
}
@@ -361,7 +361,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
361361
// Ensure that we have kept track of the number of clusters correctly.
362362
// TODO: The total_clb_num variable could probably just be replaced by
363363
// 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);
365365

366366
return num_used_type_instances;
367367
}

vpr/src/pack/cluster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
#include "cluster_util.h"
1212

1313
class Prepacker;
14+
class ClusterLegalizer;
1415

1516
std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& packer_opts,
1617
const t_analysis_opts& analysis_opts,
1718
const t_arch* arch,
1819
Prepacker& prepacker,
20+
ClusterLegalizer& cluster_legalizer,
1921
const std::unordered_set<AtomNetId>& is_clock,
2022
const std::unordered_set<AtomNetId>& is_global,
2123
bool allow_unrelated_clustering,

0 commit comments

Comments
 (0)