Skip to content

Commit d2eb199

Browse files
[SQUASH ME] Removed the prepacker from the global scope.
1 parent 76564d2 commit d2eb199

14 files changed

+158
-132
lines changed

vpr/src/base/vpr_context.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ struct AtomContext : public Context {
7979

8080
/// @brief Mappings to/from the Atom Netlist to physically described .blif models
8181
AtomLookup lookup;
82-
83-
/// @brief Prepacker object which performs prepacking and stores the pack
84-
/// molecules. Has a method to get the pack molecule of an AtomBlock.
85-
/// TODO: This is mainly only used in the clusterer. It can probably be
86-
/// removed from the AtomContext entirely.
87-
/// FIXME: Move this to the clustering helper context. It makes more sense there.
88-
Prepacker prepacker;
8982
};
9083

9184
/**

vpr/src/pack/cluster.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,17 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
186186
}
187187

188188
// Assign gain scores to atoms and sort them based on the scores.
189-
auto seed_atoms = initialize_seed_atoms(packer_opts.cluster_seed_type, max_molecule_stats, atom_criticality);
189+
auto seed_atoms = initialize_seed_atoms(packer_opts.cluster_seed_type,
190+
max_molecule_stats,
191+
prepacker,
192+
atom_criticality);
190193

191194
/* index of next most timing critical block */
192195
int seed_index = 0;
193-
istart = get_highest_gain_seed_molecule(seed_index, seed_atoms, cluster_legalizer);
196+
istart = get_highest_gain_seed_molecule(seed_index,
197+
seed_atoms,
198+
prepacker,
199+
cluster_legalizer);
194200

195201
print_pack_status_header();
196202

@@ -279,6 +285,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
279285
packer_opts.feasible_block_array_size,
280286
&cluster_stats.num_unrelated_clustering_attempts,
281287
cur_cluster_placement_stats_ptr,
288+
prepacker,
282289
cluster_legalizer,
283290
clb_inter_blk_nets,
284291
legalization_cluster_id,
@@ -308,6 +315,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
308315
prev_molecule = next_molecule;
309316

310317
try_fill_cluster(cluster_legalizer,
318+
prepacker,
311319
packer_opts,
312320
cur_cluster_placement_stats_ptr,
313321
prev_molecule,
@@ -343,7 +351,10 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
343351

344352
if (is_cluster_legal) {
345353
// Pick new seed.
346-
istart = get_highest_gain_seed_molecule(seed_index, seed_atoms, cluster_legalizer);
354+
istart = get_highest_gain_seed_molecule(seed_index,
355+
seed_atoms,
356+
prepacker,
357+
cluster_legalizer);
347358
// Update cluster stats.
348359
if (packer_opts.timing_driven && num_blocks_hill_added > 0)
349360
cluster_stats.blocks_since_last_analysis += num_blocks_hill_added;

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,7 @@ static void update_molecule_chain_info(t_pack_molecule* chain_molecule, const t_
955955
*/
956956
static void revert_place_atom_block(const AtomBlockId blk_id,
957957
t_lb_router_data* router_data,
958+
const Prepacker& prepacker,
958959
vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster) {
959960
auto& atom_ctx = g_vpr_ctx.mutable_atom();
960961

@@ -971,7 +972,7 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
971972
*/
972973

973974
t_pb* next = pb->parent_pb;
974-
revalid_molecules(pb);
975+
revalid_molecules(pb, prepacker);
975976
free_pb(pb);
976977
pb = next;
977978

@@ -988,7 +989,7 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
988989
/* If the code gets here, then that means that placing the initial seed molecule
989990
* failed, don't free the actual complex block itself as the seed needs to find
990991
* another placement */
991-
revalid_molecules(pb);
992+
revalid_molecules(pb, prepacker);
992993
free_pb(pb);
993994
}
994995
}
@@ -1114,6 +1115,7 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
11141115
// TODO: Remove these global accesses.
11151116
// AtomContext used for:
11161117
// - printing verbose statements
1118+
// - Looking up the primitive pb
11171119
const AtomContext& atom_ctx = g_vpr_ctx.atom();
11181120
// FloorplanningContext used for:
11191121
// - Checking if the atom can be placed in the cluster for floorplanning
@@ -1332,7 +1334,7 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
13321334
continue;
13331335

13341336
/* invalidate all molecules that share atom block with current molecule */
1335-
t_pack_molecule* cur_molecule = atom_ctx.prepacker.get_atom_molecule(atom_blk_id);
1337+
t_pack_molecule* cur_molecule = prepacker.get_atom_molecule(atom_blk_id);
13361338
// TODO: This should really be named better. Something like
13371339
// "is_clustered". and then it should be set to true.
13381340
// Right now, valid implies "not clustered" which is
@@ -1359,7 +1361,7 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
13591361
for (int i = 0; i < failed_location; i++) {
13601362
AtomBlockId atom_blk_id = molecule->atom_block_ids[i];
13611363
if (atom_blk_id) {
1362-
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster);
1364+
revert_place_atom_block(atom_blk_id, cluster.router_data, prepacker, atom_cluster);
13631365
}
13641366
}
13651367

@@ -1504,7 +1506,7 @@ void ClusterLegalizer::destroy_cluster(LegalizationClusterId cluster_id) {
15041506
for (int i = 0; i < molecule_size; i++) {
15051507
AtomBlockId atom_blk_id = mol->atom_block_ids[i];
15061508
if (atom_blk_id) {
1507-
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster);
1509+
revert_place_atom_block(atom_blk_id, cluster.router_data, prepacker, atom_cluster);
15081510
}
15091511
}
15101512
}
@@ -1558,18 +1560,18 @@ bool ClusterLegalizer::check_cluster_legality(LegalizationClusterId cluster_id)
15581560
return try_intra_lb_route(cluster.router_data, log_verbosity, &mode_status);
15591561
}
15601562

1561-
void ClusterLegalizer::init(const AtomNetlist& atom_netlist,
1562-
const Prepacker& prepacker,
1563-
const std::vector<t_logical_block_type>& logical_block_types,
1564-
std::vector<t_lb_type_rr_node>* t_lb_type_rr_graphs,
1565-
size_t t_num_models,
1566-
const std::vector<std::string>& target_external_pin_util_str,
1567-
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
1568-
ClusterLegalizationStrategy t_cluster_legalization_strategy,
1569-
bool t_enable_pin_feasibility_filter,
1570-
int t_feasible_block_array_size,
1571-
int t_log_verbosity,
1572-
int t_force_site) {
1563+
ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
1564+
const Prepacker& t_prepacker,
1565+
const std::vector<t_logical_block_type>& logical_block_types,
1566+
std::vector<t_lb_type_rr_node>* t_lb_type_rr_graphs,
1567+
size_t t_num_models,
1568+
const std::vector<std::string>& target_external_pin_util_str,
1569+
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
1570+
ClusterLegalizationStrategy t_cluster_legalization_strategy,
1571+
bool t_enable_pin_feasibility_filter,
1572+
int t_feasible_block_array_size,
1573+
int t_log_verbosity,
1574+
int t_force_site) : prepacker(t_prepacker) {
15731575
// Ensure that this is not being initialized twice.
15741576
VTR_ASSERT(cluster_placement_stats == nullptr &&
15751577
primitives_list == nullptr &&

vpr/src/pack/cluster_legalizer.h

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,27 +90,28 @@ class ClusterLegalizer {
9090
const t_ext_pin_util& max_external_pin_util);
9191
public:
9292

93-
// Default constructor. Use the init method to initialize the legalizer.
94-
ClusterLegalizer() = default;
93+
// Explicitly deleted default constructor. Need to use other constructor to
94+
// initialize state correctly.
95+
ClusterLegalizer() = delete;
9596

9697
/*
9798
* @brief Initialize the ClusterLegalizer class. Must be called before use.
9899
*
99100
* Allocates internal state.
100101
* FIXME: See if we can simplify the parameters. Can any of these be inferred?
101102
*/
102-
void init(const AtomNetlist& atom_netlist,
103-
const Prepacker& prepacker,
104-
const std::vector<t_logical_block_type>& logical_block_types,
105-
std::vector<t_lb_type_rr_node>* t_lb_type_rr_graphs,
106-
size_t t_num_models,
107-
const std::vector<std::string>& target_external_pin_util_str,
108-
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
109-
ClusterLegalizationStrategy t_cluster_legalization_strategy,
110-
bool t_enable_pin_feasibility_filter,
111-
int t_feasible_block_array_size,
112-
int t_log_verbosity,
113-
int t_force_site = -1);
103+
ClusterLegalizer(const AtomNetlist& atom_netlist,
104+
const Prepacker& t_prepacker,
105+
const std::vector<t_logical_block_type>& logical_block_types,
106+
std::vector<t_lb_type_rr_node>* t_lb_type_rr_graphs,
107+
size_t t_num_models,
108+
const std::vector<std::string>& target_external_pin_util_str,
109+
const t_pack_high_fanout_thresholds& high_fanout_thresholds,
110+
ClusterLegalizationStrategy t_cluster_legalization_strategy,
111+
bool t_enable_pin_feasibility_filter,
112+
int t_feasible_block_array_size,
113+
int t_log_verbosity,
114+
int t_force_site = -1);
114115

115116
// This class allocates and deallocates memory within. This class should not
116117
// be copied or moved to prevent it from double freeing / losing pointers.
@@ -297,5 +298,7 @@ class ClusterLegalizer {
297298

298299
// TODO: Figure out what this does and why...
299300
int force_site;
301+
302+
const Prepacker& prepacker;
300303
};
301304

0 commit comments

Comments
 (0)