9
9
#include " read_netlist.h"
10
10
11
11
12
- // The name suffix of the new block (if exists)
12
+ // The name suffix of the new block (if exists)
13
+ // This suffex is useful in preventing duplicate high-level cluster block names
13
14
const char * name_suffix = " _m" ;
14
15
15
16
/* ****************** Static Functions ********************/
16
- // static void set_atom_pin_mapping(const ClusteredNetlist& clb_nlist, const AtomBlockId atom_blk, const AtomPortId atom_port, const t_pb_graph_pin* gpin);
17
17
static void load_atom_index_for_pb_pin (t_pb_routes& pb_route, int ipin);
18
18
static void load_internal_to_block_net_nums (const t_logical_block_type_ptr type, t_pb_routes& pb_route);
19
- // static bool count_children_pbs(const t_pb* pb);
20
19
static void fix_atom_pin_mapping (const AtomBlockId blk);
21
20
22
21
static void fix_cluster_pins_after_moving (const ClusterBlockId clb_index);
@@ -41,6 +40,7 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
41
40
int molecule_size,
42
41
ClusterBlockId clb_index,
43
42
bool is_added);
43
+
44
44
/* **************** API functions ***********************/
45
45
ClusterBlockId atom_to_cluster (const AtomBlockId& atom) {
46
46
auto & atom_ctx = g_vpr_ctx.atom ();
@@ -65,19 +65,18 @@ void remove_mol_from_cluster(const t_pack_molecule* molecule,
65
65
t_lb_router_data*& router_data) {
66
66
auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
67
67
68
- // re-build router_data structure for this cluster
69
- if (!router_data_ready)
70
- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
71
-
72
- // remove atom from router_data
73
68
for (int i_atom = 0 ; i_atom < molecule_size; i_atom++) {
74
69
if (molecule->atom_block_ids [i_atom]) {
75
- remove_atom_from_target (router_data, molecule->atom_block_ids [i_atom]);
76
70
auto it = old_clb_atoms->find (molecule->atom_block_ids [i_atom]);
77
71
if (it != old_clb_atoms->end ())
78
72
old_clb_atoms->erase (molecule->atom_block_ids [i_atom]);
79
73
}
80
74
}
75
+
76
+ // re-build router_data structure for this cluster
77
+ if (!router_data_ready)
78
+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
79
+
81
80
update_cluster_pb_stats (molecule, molecule_size, old_clb, false );
82
81
}
83
82
@@ -87,7 +86,7 @@ void commit_mol_move(const ClusterBlockId& old_clb,
87
86
bool new_clb_created) {
88
87
auto & device_ctx = g_vpr_ctx.device ();
89
88
90
- // Place the new cluster if this function called during placement (after the initial placement is done)
89
+ // place the new cluster if this function called during placement (after the initial placement is done)
91
90
if (!during_packing && new_clb_created) {
92
91
int imacro;
93
92
g_vpr_ctx.mutable_placement ().block_locs .resize (g_vpr_ctx.placement ().block_locs .size () + 1 );
@@ -100,6 +99,7 @@ void commit_mol_move(const ClusterBlockId& old_clb,
100
99
t_lb_router_data* lb_load_router_data (std::vector<t_lb_type_rr_node>* lb_type_rr_graphs, const ClusterBlockId& clb_index, const std::unordered_set<AtomBlockId>* clb_atoms) {
101
100
// build data structures used by intra-logic block router
102
101
auto & cluster_ctx = g_vpr_ctx.clustering ();
102
+ auto & atom_ctx = g_vpr_ctx.atom ();
103
103
auto block_type = cluster_ctx.clb_nlist .block_type (clb_index);
104
104
t_lb_router_data* router_data = alloc_and_load_router_data (&lb_type_rr_graphs[block_type->index ], block_type);
105
105
@@ -109,14 +109,19 @@ t_lb_router_data* lb_load_router_data(std::vector<t_lb_type_rr_node>* lb_type_rr
109
109
110
110
for (auto atom_id : *clb_atoms) {
111
111
add_atom_as_target (router_data, atom_id);
112
+ const t_pb* pb = atom_ctx.lookup .atom_pb (atom_id);
113
+ while (pb) {
114
+ set_reset_pb_modes (router_data, pb, true );
115
+ pb = pb->parent_pb ;
116
+ }
112
117
}
113
118
return (router_data);
114
119
}
115
120
116
121
bool start_new_cluster_for_mol (t_pack_molecule* molecule,
117
122
const t_logical_block_type_ptr& type,
118
- const int mode,
119
- const int feasible_block_array_size,
123
+ const int & mode,
124
+ const int & feasible_block_array_size,
120
125
bool enable_pin_feasibility_filter,
121
126
ClusterBlockId clb_index,
122
127
bool during_packing,
@@ -148,10 +153,11 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
148
153
149
154
e_block_pack_status pack_result = e_block_pack_status::BLK_STATUS_UNDEFINED;
150
155
pb->mode = mode;
151
- reset_cluster_placement_stats (&(helper_ctx.cluster_placement_stats [type->index ]));
156
+ t_cluster_placement_stats* cluster_placement_stats = &(helper_ctx.cluster_placement_stats [type->index ]);
157
+ reset_cluster_placement_stats (cluster_placement_stats);
152
158
set_mode_cluster_placement_stats (pb->pb_graph_node , mode);
153
159
154
- pack_result = try_pack_molecule (&(helper_ctx. cluster_placement_stats [type-> index ]) ,
160
+ pack_result = try_pack_molecule (cluster_placement_stats,
155
161
molecule,
156
162
helper_ctx.primitives_list ,
157
163
pb,
@@ -178,6 +184,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
178
184
pb->name = vtr::strdup (new_name.c_str ());
179
185
clb_index = cluster_ctx.clb_nlist .create_block (new_name.c_str (), pb, type);
180
186
helper_ctx.total_clb_num ++;
187
+ int molecule_size = get_array_size_of_molecule (molecule);
188
+ update_cluster_pb_stats (molecule, molecule_size, clb_index, true );
181
189
182
190
// If you are still in packing, update the clustering data. Otherwise, update the clustered netlist.
183
191
if (during_packing) {
@@ -200,10 +208,9 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
200
208
201
209
bool pack_mol_in_existing_cluster (t_pack_molecule* molecule,
202
210
int molecule_size,
203
- const ClusterBlockId new_clb,
211
+ const ClusterBlockId& new_clb,
204
212
std::unordered_set<AtomBlockId>* new_clb_atoms,
205
213
bool during_packing,
206
- bool is_swap,
207
214
t_clustering_data& clustering_data,
208
215
t_lb_router_data*& router_data) {
209
216
auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
@@ -222,8 +229,7 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
222
229
return false ;
223
230
224
231
// re-build router_data structure for this cluster
225
- if (!is_swap)
226
- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
232
+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
227
233
228
234
pack_result = try_pack_molecule (&(helper_ctx.cluster_placement_stats [block_type->index ]),
229
235
molecule,
@@ -262,11 +268,9 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
262
268
update_cluster_pb_stats (molecule, molecule_size, new_clb, true );
263
269
}
264
270
265
- if (!is_swap) {
266
- // Free clustering router data
267
- free_router_data (router_data);
268
- router_data = nullptr ;
269
- }
271
+ // Free clustering router data
272
+ free_router_data (router_data);
273
+ router_data = nullptr ;
270
274
271
275
return (pack_result == e_block_pack_status::BLK_PASSED);
272
276
}
@@ -735,4 +739,4 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
735
739
cur_pb = cur_pb->parent_pb ;
736
740
}
737
741
}
738
- }
742
+ }
0 commit comments