@@ -34,7 +34,7 @@ static void fix_cluster_net_after_moving(const t_pack_molecule* molecule,
3434 const ClusterBlockId& new_clb);
3535
3636static void rebuild_cluster_placement_stats (const ClusterBlockId& clb_index,
37- const std::unordered_set<AtomBlockId>* clb_atoms);
37+ const std::unordered_set<AtomBlockId>& clb_atoms);
3838
3939static void update_cluster_pb_stats (const t_pack_molecule* molecule,
4040 int molecule_size,
@@ -47,29 +47,25 @@ ClusterBlockId atom_to_cluster(const AtomBlockId& atom) {
4747 return (atom_ctx.lookup .atom_clb (atom));
4848}
4949
50- std::unordered_set<AtomBlockId>* cluster_to_atoms (const ClusterBlockId& cluster) {
51- auto & helper_ctx = g_vpr_ctx. mutable_cl_helper ( );
50+ const std::unordered_set<AtomBlockId>& cluster_to_atoms (ClusterBlockId cluster) {
51+ const auto & atoms = cluster_to_mutable_atoms (cluster );
5252
53- // If the lookup is not built yet, build it first
54- if (helper_ctx.atoms_lookup .empty ())
55- init_clb_atoms_lookup (helper_ctx.atoms_lookup );
56-
57- return &(helper_ctx.atoms_lookup [cluster]);
53+ return atoms;
5854}
5955
6056void remove_mol_from_cluster (const t_pack_molecule* molecule,
6157 int molecule_size,
6258 ClusterBlockId& old_clb,
63- std::unordered_set<AtomBlockId>* old_clb_atoms,
59+ std::unordered_set<AtomBlockId>& old_clb_atoms,
6460 bool router_data_ready,
6561 t_lb_router_data*& router_data) {
6662 auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
6763
6864 for (int i_atom = 0 ; i_atom < molecule_size; i_atom++) {
6965 if (molecule->atom_block_ids [i_atom]) {
70- auto it = old_clb_atoms-> find (molecule->atom_block_ids [i_atom]);
71- if (it != old_clb_atoms-> end ())
72- old_clb_atoms-> erase (molecule->atom_block_ids [i_atom]);
66+ auto it = old_clb_atoms. find (molecule->atom_block_ids [i_atom]);
67+ if (it != old_clb_atoms. end ())
68+ old_clb_atoms. erase (molecule->atom_block_ids [i_atom]);
7369 }
7470 }
7571
@@ -96,18 +92,16 @@ void commit_mol_move(const ClusterBlockId& old_clb,
9692 }
9793}
9894
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) {
95+ t_lb_router_data* lb_load_router_data (std::vector<t_lb_type_rr_node>* lb_type_rr_graphs,
96+ const ClusterBlockId& clb_index,
97+ const std::unordered_set<AtomBlockId>& clb_atoms) {
10098 // build data structures used by intra-logic block router
10199 auto & cluster_ctx = g_vpr_ctx.clustering ();
102100 auto & atom_ctx = g_vpr_ctx.atom ();
103101 auto block_type = cluster_ctx.clb_nlist .block_type (clb_index);
104102 t_lb_router_data* router_data = alloc_and_load_router_data (&lb_type_rr_graphs[block_type->index ], block_type);
105103
106- // iterate over atoms of the current cluster and add them to router data
107- if (!clb_atoms)
108- return router_data;
109-
110- for (auto atom_id : *clb_atoms) {
104+ for (auto atom_id : clb_atoms) {
111105 add_atom_as_target (router_data, atom_id);
112106 const t_pb* pb = atom_ctx.lookup .atom_pb (atom_id);
113107 while (pb) {
@@ -209,7 +203,7 @@ bool start_new_cluster_for_mol(t_pack_molecule* molecule,
209203bool pack_mol_in_existing_cluster (t_pack_molecule* molecule,
210204 int molecule_size,
211205 const ClusterBlockId& new_clb,
212- std::unordered_set<AtomBlockId>* new_clb_atoms,
206+ std::unordered_set<AtomBlockId>& new_clb_atoms,
213207 bool during_packing,
214208 t_clustering_data& clustering_data,
215209 t_lb_router_data*& router_data) {
@@ -262,7 +256,7 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
262256
263257 for (int i_atom = 0 ; i_atom < molecule_size; i_atom++) {
264258 if (molecule->atom_block_ids [i_atom]) {
265- new_clb_atoms-> insert (molecule->atom_block_ids [i_atom]);
259+ new_clb_atoms. insert (molecule->atom_block_ids [i_atom]);
266260 }
267261 }
268262 update_cluster_pb_stats (molecule, molecule_size, new_clb, true );
@@ -364,10 +358,10 @@ static void fix_cluster_net_after_moving(const t_pack_molecule* molecule,
364358 fix_cluster_pins_after_moving (old_clb);
365359 fix_cluster_pins_after_moving (new_clb);
366360
367- for (auto & atom_blk : *( cluster_to_atoms (old_clb) ))
361+ for (AtomBlockId atom_blk : cluster_to_atoms (old_clb))
368362 fix_atom_pin_mapping (atom_blk);
369363
370- for (auto & atom_blk : *( cluster_to_atoms (new_clb) ))
364+ for (AtomBlockId atom_blk : cluster_to_atoms (new_clb))
371365 fix_atom_pin_mapping (atom_blk);
372366
373367 cluster_ctx.clb_nlist .remove_and_compress ();
@@ -641,7 +635,7 @@ static bool count_children_pbs(const t_pb* pb) {
641635#endif
642636
643637static void rebuild_cluster_placement_stats (const ClusterBlockId& clb_index,
644- const std::unordered_set<AtomBlockId>* clb_atoms) {
638+ const std::unordered_set<AtomBlockId>& clb_atoms) {
645639 auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
646640 auto & cluster_ctx = g_vpr_ctx.clustering ();
647641 auto & atom_ctx = g_vpr_ctx.atom ();
@@ -650,7 +644,7 @@ static void rebuild_cluster_placement_stats(const ClusterBlockId& clb_index,
650644 reset_cluster_placement_stats (cluster_placement_stats);
651645 set_mode_cluster_placement_stats (cluster_ctx.clb_nlist .block_pb (clb_index)->pb_graph_node , cluster_ctx.clb_nlist .block_pb (clb_index)->mode );
652646
653- for (auto & atom : * clb_atoms) {
647+ for (AtomBlockId atom : clb_atoms) {
654648 const t_pb* atom_pb = atom_ctx.lookup .atom_pb (atom);
655649 commit_primitive (cluster_placement_stats, atom_pb->pb_graph_node );
656650 }
@@ -744,3 +738,13 @@ static void update_cluster_pb_stats(const t_pack_molecule* molecule,
744738 }
745739 }
746740}
741+
742+ std::unordered_set<AtomBlockId>& cluster_to_mutable_atoms (ClusterBlockId cluster) {
743+ auto & helper_ctx = g_vpr_ctx.mutable_cl_helper ();
744+
745+ // If the lookup is not built yet, build it first
746+ if (helper_ctx.atoms_lookup .empty ())
747+ init_clb_atoms_lookup (helper_ctx.atoms_lookup );
748+
749+ return helper_ctx.atoms_lookup [cluster];
750+ }
0 commit comments