Skip to content

Commit 55f3ef1

Browse files
[Prepacker] Removed Revalid Molecules Method
Found that the revalid molecules method was more complicated than it needed to be in the context of the Cluster Legalizer. Simplified its code so that it makes more sense.
1 parent 49bbe80 commit 55f3ef1

File tree

1 file changed

+22
-62
lines changed

1 file changed

+22
-62
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 22 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -997,61 +997,25 @@ static void update_molecule_chain_info(t_pack_molecule* chain_molecule, const t_
997997
VTR_ASSERT(false);
998998
}
999999

1000-
/**
1001-
* @brief Revalidate the molecules associated with this pb. The mol_validated
1002-
* flag is used to check if the mol has already been validated.
1000+
/*
1001+
* @brief Reset molecule information created while trying to cluster it.
1002+
*
1003+
* This code only resets information that has to do with long chains.
1004+
*
1005+
* TODO: This information should not be stored in the molecule, but should be
1006+
* stored in the ClusterLegalizer class instead.
10031007
*/
1004-
static void revalid_molecules(const t_pb* pb,
1005-
bool &mol_validated,
1006-
const Prepacker& prepacker) {
1007-
const t_pb_type* pb_type = pb->pb_graph_node->pb_type;
1008-
1009-
if (pb_type->blif_model == nullptr) {
1010-
int mode = pb->mode;
1011-
for (int i = 0; i < pb_type->modes[mode].num_pb_type_children && pb->child_pbs != nullptr; i++) {
1012-
for (int j = 0; j < pb_type->modes[mode].pb_type_children[i].num_pb && pb->child_pbs[i] != nullptr; j++) {
1013-
if (pb->child_pbs[i][j].name != nullptr || pb->child_pbs[i][j].child_pbs != nullptr) {
1014-
revalid_molecules(&pb->child_pbs[i][j], mol_validated, prepacker);
1015-
}
1016-
}
1017-
}
1018-
} else {
1019-
//Primitive
1020-
auto& atom_ctx = g_vpr_ctx.mutable_atom();
1021-
1022-
auto blk_id = atom_ctx.lookup.pb_atom(pb);
1023-
if (blk_id) {
1024-
/* If any molecules were marked invalid because of this logic block getting packed, mark them valid */
1025-
1026-
//Update atom netlist mapping
1027-
atom_ctx.lookup.set_atom_clb(blk_id, ClusterBlockId::INVALID());
1028-
atom_ctx.lookup.set_atom_pb(blk_id, nullptr);
1029-
1030-
t_pack_molecule* cur_molecule = prepacker.get_atom_molecule(blk_id);
1031-
if (!mol_validated) {
1032-
int i;
1033-
for (i = 0; i < get_array_size_of_molecule(cur_molecule); i++) {
1034-
if (cur_molecule->atom_block_ids[i]) {
1035-
if (atom_ctx.lookup.atom_clb(cur_molecule->atom_block_ids[i]) != ClusterBlockId::INVALID()) {
1036-
break;
1037-
}
1038-
}
1039-
}
1040-
/* All atom blocks are open for this molecule, place back in queue */
1041-
if (i == get_array_size_of_molecule(cur_molecule)) {
1042-
mol_validated = true;
1043-
// when invalidating a molecule check if it's a chain molecule
1044-
// that is part of a long chain. If so, check if this molecule
1045-
// have modified the chain_id value based on the stale packing
1046-
// then reset the chain id and the first packed molecule pointer
1047-
// this is packing is being reset
1048-
if (cur_molecule->is_chain() && cur_molecule->chain_info->is_long_chain && cur_molecule->chain_info->first_packed_molecule == cur_molecule) {
1049-
cur_molecule->chain_info->first_packed_molecule = nullptr;
1050-
cur_molecule->chain_info->chain_id = -1;
1051-
}
1052-
}
1053-
}
1054-
}
1008+
static void reset_molecule_info(t_pack_molecule* mol) {
1009+
// when invalidating a molecule check if it's a chain molecule
1010+
// that is part of a long chain. If so, check if this molecule
1011+
// have modified the chain_id value based on the stale packing
1012+
// then reset the chain id and the first packed molecule pointer
1013+
// this is packing is being reset
1014+
if (mol->is_chain()
1015+
&& mol->chain_info->is_long_chain
1016+
&& mol->chain_info->first_packed_molecule == mol) {
1017+
mol->chain_info->first_packed_molecule = nullptr;
1018+
mol->chain_info->chain_id = -1;
10551019
}
10561020
}
10571021

@@ -1060,8 +1024,6 @@ static void revalid_molecules(const t_pb* pb,
10601024
*/
10611025
static void revert_place_atom_block(const AtomBlockId blk_id,
10621026
t_lb_router_data* router_data,
1063-
bool &mol_validated,
1064-
const Prepacker& prepacker,
10651027
vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster) {
10661028
const AtomContext& atom_ctx = g_vpr_ctx.atom();
10671029
AtomContext& mutable_atom_ctx = g_vpr_ctx.mutable_atom();
@@ -1079,7 +1041,6 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
10791041
*/
10801042

10811043
t_pb* next = pb->parent_pb;
1082-
revalid_molecules(pb, mol_validated, prepacker);
10831044
free_pb(pb);
10841045
pb = next;
10851046

@@ -1096,7 +1057,6 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
10961057
/* If the code gets here, then that means that placing the initial seed molecule
10971058
* failed, don't free the actual complex block itself as the seed needs to find
10981059
* another placement */
1099-
revalid_molecules(pb, mol_validated, prepacker);
11001060
free_pb(pb);
11011061
}
11021062
}
@@ -1472,13 +1432,13 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
14721432
remove_atom_from_target(cluster.router_data, atom_blk_id);
14731433
}
14741434
}
1475-
bool mol_validated = false;
14761435
for (int i = 0; i < failed_location; i++) {
14771436
AtomBlockId atom_blk_id = molecule->atom_block_ids[i];
14781437
if (atom_blk_id) {
1479-
revert_place_atom_block(atom_blk_id, cluster.router_data, mol_validated, prepacker_, atom_cluster_);
1438+
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster_);
14801439
}
14811440
}
1441+
reset_molecule_info(molecule);
14821442

14831443
// Record the failure of this molecule in the current pb stats
14841444
record_molecule_failure(molecule, cluster.pb);
@@ -1615,14 +1575,14 @@ void ClusterLegalizer::destroy_cluster(LegalizationClusterId cluster_id) {
16151575
molecule_cluster_[mol] == cluster_id);
16161576
molecule_cluster_[mol] = LegalizationClusterId::INVALID();
16171577
// Revert the placement of all blocks in the molecule.
1618-
bool mol_validated = false;
16191578
int molecule_size = get_array_size_of_molecule(mol);
16201579
for (int i = 0; i < molecule_size; i++) {
16211580
AtomBlockId atom_blk_id = mol->atom_block_ids[i];
16221581
if (atom_blk_id) {
1623-
revert_place_atom_block(atom_blk_id, cluster.router_data, mol_validated, prepacker_, atom_cluster_);
1582+
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster_);
16241583
}
16251584
}
1585+
reset_molecule_info(mol);
16261586
}
16271587
cluster.molecules.clear();
16281588
// Free the rest of the cluster data.

0 commit comments

Comments
 (0)