10
10
#include " read_netlist.h"
11
11
#include < cstring>
12
12
13
- // The name suffix of the new block (if exists)
13
+ // The name suffix of the new block (if exists)
14
+ // This suffex is useful in preventing duplicate high-level cluster block names
14
15
const char * name_suffix = " _m" ;
15
16
16
17
/* ****************** Static Functions ********************/
17
- // static void set_atom_pin_mapping(const ClusteredNetlist& clb_nlist, const AtomBlockId atom_blk, const AtomPortId atom_port, const t_pb_graph_pin* gpin);
18
18
static void load_atom_index_for_pb_pin (t_pb_routes& pb_route, int ipin);
19
19
static void load_internal_to_block_net_nums (const t_logical_block_type_ptr type, t_pb_routes& pb_route);
20
- // static bool count_children_pbs(const t_pb* pb);
21
20
static void fix_atom_pin_mapping (const AtomBlockId blk);
22
21
23
22
static void fix_cluster_pins_after_moving (const ClusterBlockId clb_index);
@@ -42,6 +41,7 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
42
41
int molecule_size,
43
42
ClusterBlockId clb_index,
44
43
bool is_added);
44
+
45
45
/* **************** API functions ***********************/
46
46
ClusterBlockId atom_to_cluster (const AtomBlockId& atom) {
47
47
auto & atom_ctx = g_vpr_ctx.atom ();
@@ -66,19 +66,18 @@ void remove_mol_from_cluster(const t_pack_molecule* molecule,
66
66
t_lb_router_data*& router_data) {
67
67
auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
68
68
69
- // re-build router_data structure for this cluster
70
- if (!router_data_ready)
71
- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
72
-
73
- // remove atom from router_data
74
69
for (int i_atom = 0 ; i_atom < molecule_size; i_atom++) {
75
70
if (molecule->atom_block_ids [i_atom]) {
76
- remove_atom_from_target (router_data, molecule->atom_block_ids [i_atom]);
77
71
auto it = old_clb_atoms->find (molecule->atom_block_ids [i_atom]);
78
72
if (it != old_clb_atoms->end ())
79
73
old_clb_atoms->erase (molecule->atom_block_ids [i_atom]);
80
74
}
81
75
}
76
+
77
+ // re-build router_data structure for this cluster
78
+ if (!router_data_ready)
79
+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , old_clb, old_clb_atoms);
80
+
82
81
update_cluster_pb_stats (molecule, molecule_size, old_clb, false );
83
82
}
84
83
@@ -101,6 +100,7 @@ void commit_mol_move(const ClusterBlockId& old_clb,
101
100
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) {
102
101
// build data structures used by intra-logic block router
103
102
auto & cluster_ctx = g_vpr_ctx.clustering ();
103
+ auto & atom_ctx = g_vpr_ctx.atom ();
104
104
auto block_type = cluster_ctx.clb_nlist .block_type (clb_index);
105
105
t_lb_router_data* router_data = alloc_and_load_router_data (&lb_type_rr_graphs[block_type->index ], block_type);
106
106
@@ -110,14 +110,19 @@ t_lb_router_data* lb_load_router_data(std::vector<t_lb_type_rr_node>* lb_type_rr
110
110
111
111
for (auto atom_id : *clb_atoms) {
112
112
add_atom_as_target (router_data, atom_id);
113
+ const t_pb* pb = atom_ctx.lookup .atom_pb (atom_id);
114
+ while (pb) {
115
+ set_reset_pb_modes (router_data, pb, true );
116
+ pb = pb->parent_pb ;
117
+ }
113
118
}
114
119
return (router_data);
115
120
}
116
121
117
122
bool start_new_cluster_for_mol (t_pack_molecule* molecule,
118
123
const t_logical_block_type_ptr& type,
119
- const int mode,
120
- const int feasible_block_array_size,
124
+ const int & mode,
125
+ const int & feasible_block_array_size,
121
126
bool enable_pin_feasibility_filter,
122
127
ClusterBlockId clb_index,
123
128
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 = 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,
@@ -177,6 +183,8 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
177
183
pb->name = vtr::strdup (new_name.c_str ());
178
184
clb_index = cluster_ctx.clb_nlist .create_block (new_name.c_str (), pb, type);
179
185
helper_ctx.total_clb_num ++;
186
+ int molecule_size = get_array_size_of_molecule (molecule);
187
+ update_cluster_pb_stats (molecule, molecule_size, clb_index, true );
180
188
181
189
// If you are still in packing, update the clustering data. Otherwise, update the clustered netlist.
182
190
if (during_packing) {
@@ -220,8 +228,7 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
220
228
return false ;
221
229
222
230
// re-build router_data structure for this cluster
223
- if (!is_swap)
224
- router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
231
+ router_data = lb_load_router_data (helper_ctx.lb_type_rr_graphs , new_clb, new_clb_atoms);
225
232
226
233
pack_result = try_pack_molecule (&(helper_ctx.cluster_placement_stats [block_type->index ]),
227
234
molecule,
@@ -259,11 +266,9 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
259
266
update_cluster_pb_stats (molecule, molecule_size, new_clb, true );
260
267
}
261
268
262
- if (!is_swap) {
263
- // Free clustering router data
264
- free_router_data (router_data);
265
- router_data = nullptr ;
266
- }
269
+ // Free clustering router data
270
+ free_router_data (router_data);
271
+ router_data = nullptr ;
267
272
268
273
return (pack_result == BLK_PASSED);
269
274
}
0 commit comments