6
6
7
7
bool move_mol_to_new_cluster (t_pack_molecule* molecule,
8
8
t_clustering_data& clustering_data,
9
- bool during_packing) {
9
+ bool during_packing,
10
+ int verbosity) {
10
11
auto & cluster_ctx = g_vpr_ctx.clustering ();
11
12
auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
12
13
auto & device_ctx = g_vpr_ctx.device ();
@@ -30,17 +31,23 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
30
31
}
31
32
32
33
if (helper_ctx.num_used_type_instances [block_type] == num_instances) {
33
- VTR_LOG ( " The utilization of block_type %s is 100%. No space for new clusters\n " , block_type->name );
34
- VTR_LOG ( " Atom %d move aborted\n " , molecule->atom_block_ids [molecule->root ]);
34
+ VTR_LOGV (verbosity > 4 , " The utilization of block_type %s is 100%. No space for new clusters\n " , block_type->name );
35
+ VTR_LOGV (verbosity > 4 , " Atom %d move aborted\n " , molecule->atom_block_ids [molecule->root ]);
35
36
return false ;
36
37
}
37
38
38
- // remove the molecule from its current cluster and check the cluster legality after
39
- is_removed = remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data, clustering_data, during_packing );
39
+ // remove the molecule from its current cluster
40
+ remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data);
40
41
41
- if (!is_removed) {
42
- VTR_LOG (" Atom: %zu move failed. Can't remove it from the old cluster\n " , molecule->atom_block_ids [molecule->root ]);
43
- return (is_removed);
42
+ // check old cluster legality after removing the molecule
43
+ is_removed = is_cluster_legal (old_router_data);
44
+
45
+ // if the cluster is legal, commit the molecule removal. Otherwise, abort the move
46
+ if (is_removed) {
47
+ commit_mol_removal (molecule, molecule_size, old_clb, during_packing, old_router_data, clustering_data);
48
+ } else {
49
+ VTR_LOGV (verbosity > 4 , " Atom: %zu move failed. Can't remove it from the old cluster\n " , molecule->atom_block_ids [molecule->root ]);
50
+ return false ;
44
51
}
45
52
46
53
// Create new cluster of the same type and mode.
@@ -52,17 +59,18 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
52
59
helper_ctx.enable_pin_feasibility_filter ,
53
60
new_clb,
54
61
during_packing,
62
+ verbosity,
55
63
clustering_data,
56
64
&router_data,
57
65
temp_cluster_pr);
58
66
59
67
// Commit or revert the move
60
68
if (is_created) {
61
69
commit_mol_move (old_clb, new_clb, during_packing, true );
62
- VTR_LOG ( " Atom:%zu is moved to a new cluster\n " , molecule->atom_block_ids [molecule->root ]);
70
+ VTR_LOGV (verbosity > 4 , " Atom:%zu is moved to a new cluster\n " , molecule->atom_block_ids [molecule->root ]);
63
71
} else {
64
72
revert_mol_move (old_clb, molecule, old_router_data, during_packing, clustering_data);
65
- VTR_LOG ( " Atom:%zu move failed. Can't start a new cluster of the same type and mode\n " , molecule->atom_block_ids [molecule->root ]);
73
+ VTR_LOGV (verbosity > 4 , " Atom:%zu move failed. Can't start a new cluster of the same type and mode\n " , molecule->atom_block_ids [molecule->root ]);
66
74
}
67
75
68
76
free_router_data (old_router_data);
@@ -80,6 +88,7 @@ bool move_mol_to_new_cluster(t_pack_molecule* molecule,
80
88
bool move_mol_to_existing_cluster (t_pack_molecule* molecule,
81
89
const ClusterBlockId& new_clb,
82
90
bool during_packing,
91
+ int verbosity,
83
92
t_clustering_data& clustering_data) {
84
93
// define required contexts
85
94
auto & cluster_ctx = g_vpr_ctx.clustering ();
@@ -94,36 +103,42 @@ bool move_mol_to_existing_cluster(t_pack_molecule* molecule,
94
103
// Check that the old and new clusters are the same type
95
104
ClusterBlockId old_clb = atom_to_cluster (root_atom_id);
96
105
if (cluster_ctx.clb_nlist .block_type (old_clb) != cluster_ctx.clb_nlist .block_type (new_clb)) {
97
- VTR_LOG ( " Atom:%zu move aborted. New and old cluster blocks are not of the same type" ,
106
+ VTR_LOGV (verbosity > 4 , " Atom:%zu move aborted. New and old cluster blocks are not of the same type" ,
98
107
root_atom_id);
99
108
return false ;
100
109
}
101
110
102
111
// Check that the old and new clusters are the mode
103
112
if (cluster_ctx.clb_nlist .block_pb (old_clb)->mode != cluster_ctx.clb_nlist .block_pb (new_clb)->mode ) {
104
- VTR_LOG ( " Atom:%zu move aborted. New and old cluster blocks are not of the same mode" ,
113
+ VTR_LOGV (verbosity > 4 , " Atom:%zu move aborted. New and old cluster blocks are not of the same mode" ,
105
114
root_atom_id);
106
115
return false ;
107
116
}
108
117
109
- // remove the molecule from its current cluster and check the cluster legality
110
- is_removed = remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data, clustering_data, during_packing);
111
- if (!is_removed) {
112
- VTR_LOG (" Atom: %zu move failed. Can't remove it from the old cluster\n " , root_atom_id);
118
+ // remove the molecule from its current cluster
119
+ remove_mol_from_cluster (molecule, molecule_size, old_clb, old_router_data);
120
+
121
+ // check old cluster legality after removing the molecule
122
+ is_removed = is_cluster_legal (old_router_data);
123
+
124
+ // if the cluster is legal, commit the molecule removal. Otherwise, abort the move
125
+ if (is_removed) {
126
+ commit_mol_removal (molecule, molecule_size, old_clb, during_packing, old_router_data, clustering_data);
127
+ } else {
128
+ VTR_LOGV (verbosity > 4 , " Atom: %zu move failed. Can't remove it from the old cluster\n " , root_atom_id);
113
129
return false ;
114
130
}
115
131
116
- rebuild_cluster_placemet_stats (new_clb, new_clb_atoms, cluster_ctx.clb_nlist .block_type (new_clb)->index , cluster_ctx.clb_nlist .block_pb (new_clb)->mode );
117
132
// Add the atom to the new cluster
118
133
is_added = pack_mol_in_existing_cluster (molecule, new_clb, new_clb_atoms, during_packing, clustering_data);
119
134
120
135
// Commit or revert the move
121
136
if (is_added) {
122
137
commit_mol_move (old_clb, new_clb, during_packing, false );
123
- VTR_LOG ( " Atom:%zu is moved to a new cluster\n " , molecule->atom_block_ids [molecule->root ]);
138
+ VTR_LOGV (verbosity > 4 , " Atom:%zu is moved to a new cluster\n " , molecule->atom_block_ids [molecule->root ]);
124
139
} else {
125
140
revert_mol_move (old_clb, molecule, old_router_data, during_packing, clustering_data);
126
- VTR_LOG ( " Atom:%zu move failed. Can't start a new cluster of the same type and mode\n " , molecule->atom_block_ids [molecule->root ]);
141
+ VTR_LOGV (verbosity > 4 , " Atom:%zu move failed. Can't start a new cluster of the same type and mode\n " , molecule->atom_block_ids [molecule->root ]);
127
142
}
128
143
129
144
free_router_data (old_router_data);
0 commit comments