@@ -14,7 +14,6 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
14
14
15
15
bool is_removed, is_created;
16
16
ClusterBlockId old_clb = atom_to_cluster (molecule->atom_block_ids [molecule->root ]);
17
- ;
18
17
int molecule_size = get_array_size_of_molecule (molecule);
19
18
20
19
PartitionRegion temp_cluster_pr;
@@ -37,7 +36,8 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
37
36
}
38
37
39
38
// remove the molecule from its current cluster
40
- remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data);
39
+ std::vector<AtomBlockId> old_clb_atoms = cluster_to_atoms (old_clb);
40
+ remove_mol_from_cluster (molecule, molecule_size, old_clb, old_clb_atoms, old_router_data);
41
41
42
42
// check old cluster legality after removing the molecule
43
43
is_removed = is_cluster_legal (old_router_data);
@@ -107,7 +107,8 @@ bool move_mol_to_existing_cluster(t_pack_molecule* molecule,
107
107
return false ;
108
108
109
109
// remove the molecule from its current cluster
110
- remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data);
110
+ std::vector<AtomBlockId> old_clb_atoms = cluster_to_atoms (old_clb);
111
+ remove_mol_from_cluster (molecule, molecule_size, old_clb, old_clb_atoms, old_router_data);
111
112
112
113
// check old cluster legality after removing the molecule
113
114
is_removed = is_cluster_legal (old_router_data);
@@ -202,63 +203,95 @@ bool swap_two_molecules(t_pack_molecule* molecule_1,
202
203
t_lb_router_data* old_1_router_data = nullptr ;
203
204
t_lb_router_data* old_2_router_data = nullptr ;
204
205
206
+ // save the atoms of the 2 clusters
207
+ std::vector<AtomBlockId> clb_1_atoms = cluster_to_atoms (clb_1);
208
+ std::vector<AtomBlockId> clb_2_atoms = cluster_to_atoms (clb_2);
209
+
205
210
// remove the molecule from its current cluster
206
- remove_mol_from_cluster (molecule_1, molecule_1_size, clb_1, old_1_router_data);
207
- // remove_mol_from_cluster(molecule_2, molecule_2_size, clb_2, old_2_router_data);
211
+ remove_mol_from_cluster (molecule_1, molecule_1_size, clb_1, clb_1_atoms, old_1_router_data);
212
+ // remove_mol_from_cluster(molecule_2, molecule_2_size, clb_2, clb_2_atoms, old_2_router_data);
208
213
209
214
// bool is_removed = is_cluster_legal(old_1_router_data);
210
215
// bool is_removed_2 = is_cluster_legal(old_2_router_data);
211
216
212
- // commit_mol_removal(molecule_1, molecule_1_size, clb_1, during_packing, old_1_router_data, clustering_data);
213
- // commit_mol_removal(molecule_2, molecule_2_size, clb_2, during_packing, old_2_router_data, clustering_data);
217
+ commit_mol_removal (molecule_1, molecule_1_size, clb_1, during_packing, old_1_router_data, clustering_data);
218
+ # if 0
214
219
for (int i_atom = 0; i_atom < molecule_1_size; i_atom++) {
215
220
if (molecule_1->atom_block_ids[i_atom]) {
216
221
revert_place_atom_block(molecule_1->atom_block_ids[i_atom], old_1_router_data);
217
222
}
218
223
}
224
+ cleanup_pb(cluster_ctx.clb_nlist.block_pb(clb_1));
225
+ #endif
226
+ #if 0
227
+ for (int i_atom = 0; i_atom < molecule_2_size; i_atom++) {
228
+ if (molecule_2->atom_block_ids[i_atom]) {
229
+ revert_place_atom_block(molecule_2->atom_block_ids[i_atom], old_2_router_data);
230
+ }
231
+ }
232
+ cleanup_pb(cluster_ctx.clb_nlist.block_pb(clb_2));
233
+ #endif
234
+
235
+ // bool is_removed = is_cluster_legal(old_1_router_data);
236
+ // bool is_removed_2 = is_cluster_legal(old_2_router_data);
237
+
238
+ remove_mol_from_cluster (molecule_2, molecule_2_size, clb_2, clb_2_atoms, old_2_router_data);
239
+ commit_mol_removal (molecule_2, molecule_2_size, clb_2, during_packing, old_2_router_data, clustering_data);
240
+
219
241
220
- cleanup_pb (cluster_ctx.clb_nlist .block_pb (clb_1));
221
- bool is_removed = is_cluster_legal (old_1_router_data);
242
+ // Add the atom to the new cluster
243
+ mol_1_success = pack_mol_in_existing_cluster (molecule_1, clb_2, clb_2_atoms, during_packing, clustering_data);
244
+
245
+ #if 1
246
+ /*
247
+ remove_mol_from_cluster(molecule_2, molecule_2_size, clb_2, old_2_router_data);
248
+ bool is_removed_2 = is_cluster_legal(old_2_router_data);
249
+ std::vector<AtomBlockId> clb_1_atoms = cluster_to_atoms(clb_1);
250
+ commit_mol_removal(molecule_2, molecule_2_size, clb_2, during_packing, old_2_router_data, clustering_data);
251
+ */
252
+ mol_2_success = pack_mol_in_existing_cluster (molecule_2, clb_1, clb_1_atoms, during_packing, clustering_data);
253
+ #endif
254
+ mol_2_success = true ;
255
+
256
+ #if 0
222
257
free_intra_lb_nets(clustering_data.intra_lb_routing[clb_1]);
223
258
clustering_data.intra_lb_routing[clb_1] = old_1_router_data->saved_lb_nets;
224
259
old_1_router_data->saved_lb_nets = nullptr;
225
-
226
- // save the atoms of the 2 clusters
227
- std::vector<AtomBlockId> clb_1_atoms = cluster_to_atoms (clb_1);
228
- std::vector<AtomBlockId> clb_2_atoms = cluster_to_atoms (clb_2);
229
-
230
- // Add the atom to the new cluster
231
- mol_1_success = pack_mol_in_existing_cluster (molecule_1, clb_2, clb_2_atoms, during_packing, clustering_data);
232
- // mol_2_success = pack_mol_in_existing_cluster(molecule_2, clb_1, clb_1_atoms, during_packing, clustering_data);
233
- mol_2_success = true ;
260
+ #endif
234
261
235
262
// commit the move if succeeded or revert if failed
236
263
if (mol_1_success && mol_2_success) {
237
- commit_mol_move (clb_1, clb_2, during_packing, false );
264
+ // commit_mol_move(clb_1, clb_2, during_packing, false);
238
265
// commit_mol_move(clb_2, clb_1, during_packing, false);
239
266
VTR_LOGV (verbosity > 4 , " Molecules swap is performed successfully\n " );
240
267
} else {
241
- revert_mol_move (clb_1, molecule_1, old_1_router_data, during_packing, clustering_data);
268
+ // revert_mol_move(clb_1, molecule_1, old_1_router_data, during_packing, clustering_data);
242
269
// revert_mol_move(clb_2, molecule_2, old_2_router_data, during_packing, clustering_data);
243
270
VTR_LOGV (verbosity > 4 , " Molecules swap failed\n " );
244
271
}
245
272
246
273
247
274
// If the move is done after packing not during it, some fixes need to be done on the clustered netlist
248
275
if (mol_1_success && mol_2_success && !during_packing) {
249
- fix_clustered_netlist (molecule_1, molecule_1_size, clb_1, clb_2);
276
+ // fix_clustered_netlist(molecule_1, molecule_1_size, clb_1, clb_2);
250
277
// fix_clustered_netlist(molecule_2, molecule_2_size, clb_2, clb_1);
251
278
}
252
279
253
280
// free memory
254
- // old_1_router_data->saved_lb_nets = nullptr;
255
- // old_2_router_data->saved_lb_nets = nullptr;
281
+ old_1_router_data->saved_lb_nets = nullptr ;
282
+ old_2_router_data->saved_lb_nets = nullptr ;
256
283
257
284
free_router_data (old_1_router_data);
258
- // free_router_data(old_2_router_data);
285
+ free_router_data (old_2_router_data);
286
+ // remove_mol_from_cluster(molecule_2, molecule_2_size, clb_2, old_2_router_data);
287
+ // bool is_removed_2 = is_cluster_legal(old_2_router_data);
288
+ // commit_mol_removal(molecule_2, molecule_2_size, clb_2, during_packing, old_2_router_data, clustering_data);
289
+ // std::vector<AtomBlockId> clb_1_atoms = cluster_to_atoms(clb_1);
290
+ // mol_2_success = pack_mol_in_existing_cluster(molecule_2, clb_1, clb_1_atoms, during_packing, clustering_data);
291
+
259
292
260
293
old_1_router_data = nullptr ;
261
- // old_2_router_data = nullptr;
294
+ old_2_router_data = nullptr ;
262
295
263
296
// return the move result
264
297
return (mol_1_success && mol_2_success);
0 commit comments