Skip to content

Commit 0af92da

Browse files
author
MohamedElgammal
committed
re-order parameters and some refactoring
1 parent 233dc26 commit 0af92da

File tree

4 files changed

+40
-24
lines changed

4 files changed

+40
-24
lines changed

vpr/src/pack/re_cluster.cpp

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
#include "cluster_router.h"
66

77
bool move_mol_to_new_cluster(t_pack_molecule* molecule,
8-
t_clustering_data& clustering_data,
98
bool during_packing,
10-
int verbosity) {
9+
int verbosity,
10+
t_clustering_data& clustering_data) {
1111
auto& cluster_ctx = g_vpr_ctx.clustering();
1212
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
1313
auto& device_ctx = g_vpr_ctx.device();
@@ -99,21 +99,12 @@ bool move_mol_to_existing_cluster(t_pack_molecule* molecule,
9999
int molecule_size = get_array_size_of_molecule(molecule);
100100
t_lb_router_data* old_router_data = nullptr;
101101
std::vector<AtomBlockId> new_clb_atoms = cluster_to_atoms(new_clb);
102-
103-
//Check that the old and new clusters are the same type
104102
ClusterBlockId old_clb = atom_to_cluster(root_atom_id);
105-
if (cluster_ctx.clb_nlist.block_type(old_clb) != cluster_ctx.clb_nlist.block_type(new_clb)) {
106-
VTR_LOGV(verbosity > 4, "Atom:%zu move aborted. New and old cluster blocks are not of the same type",
107-
root_atom_id);
108-
return false;
109-
}
110103

111-
//Check that the old and new clusters are the mode
112-
if (cluster_ctx.clb_nlist.block_pb(old_clb)->mode != cluster_ctx.clb_nlist.block_pb(new_clb)->mode) {
113-
VTR_LOGV(verbosity > 4, "Atom:%zu move aborted. New and old cluster blocks are not of the same mode",
114-
root_atom_id);
104+
//check old and new clusters compitability
105+
bool is_compitable = check_type_and_mode_compitability(old_clb, new_clb, verbosity);
106+
if (!is_compitable)
115107
return false;
116-
}
117108

118109
//remove the molecule from its current cluster
119110
remove_mol_from_cluster(molecule, molecule_size, old_clb, old_router_data);

vpr/src/pack/re_cluster.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
* - Second, during placement (during_packing variable should be false)
2424
*/
2525
bool move_mol_to_new_cluster(t_pack_molecule* molecule,
26-
t_clustering_data& clustering_data,
2726
bool during_packing,
28-
int verbosity);
27+
int verbosity,
28+
t_clustering_data& clustering_data);
2929

3030
/**
3131
* @brief This function moves a molecule out of its cluster to another cluster that already exists.

vpr/src/pack/re_cluster_util.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const char* name_suffix = "_m";
1717
//static void set_atom_pin_mapping(const ClusteredNetlist& clb_nlist, const AtomBlockId atom_blk, const AtomPortId atom_port, const t_pb_graph_pin* gpin);
1818
static void load_atom_index_for_pb_pin(t_pb_routes& pb_route, int ipin);
1919
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);
20+
//static bool count_children_pbs(const t_pb* pb);
2121
static void fix_atom_pin_mapping(const AtomBlockId blk);
2222

2323
static void fix_cluster_pins_after_moving(const ClusterBlockId clb_index);
@@ -36,9 +36,9 @@ static void fix_cluster_net_after_moving(const t_pack_molecule* molecule,
3636
const ClusterBlockId& new_clb);
3737

3838
static void rebuild_cluster_placemet_stats(const ClusterBlockId& clb_index,
39-
const std::vector<AtomBlockId>& clb_atoms,
40-
int type_idx,
41-
int mode);
39+
const std::vector<AtomBlockId>& clb_atoms,
40+
int type_idx,
41+
int mode);
4242

4343
/***************** API functions ***********************/
4444
ClusterBlockId atom_to_cluster(const AtomBlockId& atom) {
@@ -196,7 +196,6 @@ bool pack_mol_in_existing_cluster(t_pack_molecule* molecule,
196196
t_logical_block_type_ptr block_type = cluster_ctx.clb_nlist.block_type(new_clb);
197197
t_pb* temp_pb = cluster_ctx.clb_nlist.block_pb(new_clb);
198198

199-
200199
//re-build cluster placement stats
201200
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);
202201

@@ -575,6 +574,7 @@ static void load_atom_index_for_pb_pin(t_pb_routes& pb_route, int ipin) {
575574
pb_route[driver].sink_pb_pin_ids.push_back(ipin);
576575
}
577576

577+
#if 0
578578
static bool count_children_pbs(const t_pb* pb) {
579579
if (pb == nullptr)
580580
return 0;
@@ -588,11 +588,12 @@ static bool count_children_pbs(const t_pb* pb) {
588588
}
589589
return false;
590590
}
591+
#endif
591592

592593
static void rebuild_cluster_placemet_stats(const ClusterBlockId& clb_index,
593-
const std::vector<AtomBlockId>& clb_atoms,
594-
int type_idx,
595-
int mode) {
594+
const std::vector<AtomBlockId>& clb_atoms,
595+
int type_idx,
596+
int mode) {
596597
auto& helper_ctx = g_vpr_ctx.mutable_cl_helper();
597598
auto& cluster_ctx = g_vpr_ctx.clustering();
598599
auto& atom_ctx = g_vpr_ctx.atom();
@@ -648,4 +649,24 @@ void commit_mol_removal(const t_pack_molecule* molecule,
648649
cluster_ctx.clb_nlist.block_pb(old_clb)->pb_route.clear();
649650
cluster_ctx.clb_nlist.block_pb(old_clb)->pb_route = alloc_and_load_pb_route(router_data->saved_lb_nets, cluster_ctx.clb_nlist.block_pb(old_clb)->pb_graph_node);
650651
}
652+
}
653+
654+
bool check_type_and_mode_compitability(const ClusterBlockId& old_clb,
655+
const ClusterBlockId& new_clb,
656+
int verbosity) {
657+
auto& cluster_ctx = g_vpr_ctx.clustering();
658+
659+
//Check that the old and new clusters are the same type
660+
if (cluster_ctx.clb_nlist.block_type(old_clb) != cluster_ctx.clb_nlist.block_type(new_clb)) {
661+
VTR_LOGV(verbosity > 4, "Move aborted. New and old cluster blocks are not of the same type");
662+
return false;
663+
}
664+
665+
//Check that the old and new clusters are the mode
666+
if (cluster_ctx.clb_nlist.block_pb(old_clb)->mode != cluster_ctx.clb_nlist.block_pb(new_clb)->mode) {
667+
VTR_LOGV(verbosity > 4, "Move aborted. New and old cluster blocks are not of the same mode");
668+
return false;
669+
}
670+
671+
return true;
651672
}

vpr/src/pack/re_cluster_util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,8 @@ void commit_mol_removal(const t_pack_molecule* molecule,
115115
t_lb_router_data*& router_data,
116116
t_clustering_data& clustering_data);
117117

118+
bool check_type_and_mode_compitability(const ClusterBlockId& old_clb,
119+
const ClusterBlockId& new_clb,
120+
int verbosity);
121+
118122
#endif

0 commit comments

Comments
 (0)