28
28
#include " place_and_route.h"
29
29
#include " place_constraints.h"
30
30
#include " place_macro.h"
31
+ #include " prepack.h"
31
32
#include " verify_clustering.h"
32
33
#include " verify_placement.h"
33
34
#include " vpr_api.h"
@@ -202,7 +203,8 @@ class APClusterPlacer {
202
203
* @param primitive_candidate_block_types A list of candidate block types for
203
204
* the given molecule.
204
205
*/
205
- static LegalizationClusterId create_new_cluster (t_pack_molecule* seed_molecule,
206
+ static LegalizationClusterId create_new_cluster (PackMoleculeId seed_molecule_id,
207
+ const Prepacker& prepacker,
206
208
ClusterLegalizer& cluster_legalizer,
207
209
const std::map<const t_model*, std::vector<t_logical_block_type_ptr>>& primitive_candidate_block_types) {
208
210
const AtomContext& atom_ctx = g_vpr_ctx.atom ();
@@ -212,7 +214,9 @@ static LegalizationClusterId create_new_cluster(t_pack_molecule* seed_molecule,
212
214
// placed into.
213
215
// TODO: The original implementation sorted based on balance. Perhaps this
214
216
// should do the same.
215
- AtomBlockId root_atom = seed_molecule->atom_block_ids [seed_molecule->root ];
217
+ VTR_ASSERT (seed_molecule_id.is_valid ());
218
+ const t_pack_molecule& seed_molecule = prepacker.get_molecule (seed_molecule_id);
219
+ AtomBlockId root_atom = seed_molecule.atom_block_ids [seed_molecule.root ];
216
220
const t_model* root_model = atom_ctx.nlist .block_model (root_atom);
217
221
218
222
auto itr = primitive_candidate_block_types.find (root_model);
@@ -224,7 +228,7 @@ static LegalizationClusterId create_new_cluster(t_pack_molecule* seed_molecule,
224
228
for (int mode = 0 ; mode < num_modes; mode++) {
225
229
e_block_pack_status pack_status = e_block_pack_status::BLK_STATUS_UNDEFINED;
226
230
LegalizationClusterId new_cluster_id;
227
- std::tie (pack_status, new_cluster_id) = cluster_legalizer.start_new_cluster (seed_molecule , type, mode);
231
+ std::tie (pack_status, new_cluster_id) = cluster_legalizer.start_new_cluster (seed_molecule_id , type, mode);
228
232
if (pack_status == e_block_pack_status::BLK_PASSED)
229
233
return new_cluster_id;
230
234
}
@@ -290,33 +294,29 @@ void FullLegalizer::create_clusters(const PartialPlacement& p_placement) {
290
294
for (size_t tile_id_idx = 0 ; tile_id_idx < num_device_tiles; tile_id_idx++) {
291
295
DeviceTileId tile_id = DeviceTileId (tile_id_idx);
292
296
// Create the molecule list
293
- std::list<t_pack_molecule* > mol_list;
297
+ std::list<PackMoleculeId > mol_list;
294
298
for (APBlockId ap_blk_id : blocks_in_tiles[tile_id]) {
295
- // FIXME: The netlist stores a const pointer to mol; but the cluster
296
- // legalizer does not accept this. Need to fix one or the other.
297
- // For now, using const_cast.
298
- t_pack_molecule* mol = const_cast <t_pack_molecule*>(ap_netlist_.block_molecule (ap_blk_id));
299
- mol_list.push_back (mol);
299
+ mol_list.push_back (ap_netlist_.block_molecule (ap_blk_id));
300
300
}
301
301
// Clustering algorithm: Create clusters one at a time.
302
302
while (!mol_list.empty ()) {
303
303
// Arbitrarily choose the first molecule as a seed molecule.
304
- t_pack_molecule* seed_mol = mol_list.front ();
304
+ PackMoleculeId seed_mol_id = mol_list.front ();
305
305
mol_list.pop_front ();
306
306
// Use the seed molecule to create a cluster for this tile.
307
- LegalizationClusterId new_cluster_id = create_new_cluster (seed_mol , cluster_legalizer, primitive_candidate_block_types);
307
+ LegalizationClusterId new_cluster_id = create_new_cluster (seed_mol_id, prepacker_ , cluster_legalizer, primitive_candidate_block_types);
308
308
// Insert all molecules that you can into the cluster.
309
309
// NOTE: If the mol_list was somehow sorted, we can just stop at
310
310
// first failure!
311
311
auto it = mol_list.begin ();
312
312
while (it != mol_list.end ()) {
313
- t_pack_molecule* mol = *it;
314
- if (!cluster_legalizer.is_molecule_compatible (mol , new_cluster_id)) {
313
+ PackMoleculeId mol_id = *it;
314
+ if (!cluster_legalizer.is_molecule_compatible (mol_id , new_cluster_id)) {
315
315
++it;
316
316
continue ;
317
317
}
318
318
// Try to insert it. If successful, remove from list.
319
- e_block_pack_status pack_status = cluster_legalizer.add_mol_to_cluster (mol , new_cluster_id);
319
+ e_block_pack_status pack_status = cluster_legalizer.add_mol_to_cluster (mol_id , new_cluster_id);
320
320
if (pack_status == e_block_pack_status::BLK_PASSED) {
321
321
it = mol_list.erase (it);
322
322
} else {
@@ -352,8 +352,9 @@ void FullLegalizer::place_clusters(const ClusteredNetlist& clb_nlist,
352
352
// Create a lookup from the AtomBlockId to the APBlockId
353
353
vtr::vector<AtomBlockId, APBlockId> atom_to_ap_block (atom_netlist_.blocks ().size ());
354
354
for (APBlockId ap_blk_id : ap_netlist_.blocks ()) {
355
- const t_pack_molecule* blk_mol = ap_netlist_.block_molecule (ap_blk_id);
356
- for (AtomBlockId atom_blk_id : blk_mol->atom_block_ids ) {
355
+ PackMoleculeId blk_mol_id = ap_netlist_.block_molecule (ap_blk_id);
356
+ const t_pack_molecule& blk_mol = prepacker_.get_molecule (blk_mol_id);
357
+ for (AtomBlockId atom_blk_id : blk_mol.atom_block_ids ) {
357
358
// See issue #2791, some of the atom_block_ids may be invalid. They
358
359
// can safely be ignored.
359
360
if (!atom_blk_id.is_valid ())
0 commit comments