Skip to content

Commit a34ebf1

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 3aecece commit a34ebf1

File tree

1 file changed

+25
-62
lines changed

1 file changed

+25
-62
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -997,61 +997,28 @@ 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.
1007+
*
1008+
* TODO: This code may be removable. Tried turning it off and found no test
1009+
* failures or QoR degredations. Should be investigated in more detail.
10031010
*/
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-
}
1011+
static void reset_molecule_info(t_pack_molecule* mol) {
1012+
// when invalidating a molecule check if it's a chain molecule
1013+
// that is part of a long chain. If so, check if this molecule
1014+
// has modified the chain_id value based on the stale packing
1015+
// then reset the chain id and the first packed molecule pointer
1016+
// this is packing is being reset
1017+
if (mol->is_chain()
1018+
&& mol->chain_info->is_long_chain
1019+
&& mol->chain_info->first_packed_molecule == mol) {
1020+
mol->chain_info->first_packed_molecule = nullptr;
1021+
mol->chain_info->chain_id = -1;
10551022
}
10561023
}
10571024

@@ -1060,8 +1027,6 @@ static void revalid_molecules(const t_pb* pb,
10601027
*/
10611028
static void revert_place_atom_block(const AtomBlockId blk_id,
10621029
t_lb_router_data* router_data,
1063-
bool &mol_validated,
1064-
const Prepacker& prepacker,
10651030
vtr::vector_map<AtomBlockId, LegalizationClusterId>& atom_cluster) {
10661031
const AtomContext& atom_ctx = g_vpr_ctx.atom();
10671032
AtomContext& mutable_atom_ctx = g_vpr_ctx.mutable_atom();
@@ -1079,7 +1044,6 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
10791044
*/
10801045

10811046
t_pb* next = pb->parent_pb;
1082-
revalid_molecules(pb, mol_validated, prepacker);
10831047
free_pb(pb);
10841048
pb = next;
10851049

@@ -1096,7 +1060,6 @@ static void revert_place_atom_block(const AtomBlockId blk_id,
10961060
/* If the code gets here, then that means that placing the initial seed molecule
10971061
* failed, don't free the actual complex block itself as the seed needs to find
10981062
* another placement */
1099-
revalid_molecules(pb, mol_validated, prepacker);
11001063
free_pb(pb);
11011064
}
11021065
}
@@ -1472,13 +1435,13 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
14721435
remove_atom_from_target(cluster.router_data, atom_blk_id);
14731436
}
14741437
}
1475-
bool mol_validated = false;
14761438
for (int i = 0; i < failed_location; i++) {
14771439
AtomBlockId atom_blk_id = molecule->atom_block_ids[i];
14781440
if (atom_blk_id) {
1479-
revert_place_atom_block(atom_blk_id, cluster.router_data, mol_validated, prepacker_, atom_cluster_);
1441+
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster_);
14801442
}
14811443
}
1444+
reset_molecule_info(molecule);
14821445

14831446
// Record the failure of this molecule in the current pb stats
14841447
record_molecule_failure(molecule, cluster.pb);
@@ -1615,14 +1578,14 @@ void ClusterLegalizer::destroy_cluster(LegalizationClusterId cluster_id) {
16151578
molecule_cluster_[mol] == cluster_id);
16161579
molecule_cluster_[mol] = LegalizationClusterId::INVALID();
16171580
// Revert the placement of all blocks in the molecule.
1618-
bool mol_validated = false;
16191581
int molecule_size = get_array_size_of_molecule(mol);
16201582
for (int i = 0; i < molecule_size; i++) {
16211583
AtomBlockId atom_blk_id = mol->atom_block_ids[i];
16221584
if (atom_blk_id) {
1623-
revert_place_atom_block(atom_blk_id, cluster.router_data, mol_validated, prepacker_, atom_cluster_);
1585+
revert_place_atom_block(atom_blk_id, cluster.router_data, atom_cluster_);
16241586
}
16251587
}
1588+
reset_molecule_info(mol);
16261589
}
16271590
cluster.molecules.clear();
16281591
// Free the rest of the cluster data.

0 commit comments

Comments
 (0)