Skip to content

Commit 3747187

Browse files
[SQUASH ME] Documented to legalizer
Removed confusing / unused variables.
1 parent f8d8330 commit 3747187

File tree

4 files changed

+208
-85
lines changed

4 files changed

+208
-85
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,12 +1194,12 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
11941194
}
11951195
}
11961196

1197+
std::vector<t_pb_graph_node*> primitives_list(max_molecule_size, nullptr);
11971198
e_block_pack_status block_pack_status = e_block_pack_status::BLK_STATUS_UNDEFINED;
11981199
while (block_pack_status != e_block_pack_status::BLK_PASSED) {
11991200
if (!get_next_primitive_list(cluster_placement_stats_ptr,
12001201
molecule,
1201-
primitives_list,
1202-
force_site)) {
1202+
primitives_list.data())) {
12031203
VTR_LOGV(log_verbosity > 3, "\t\tFAILED No candidate primitives available\n");
12041204
block_pack_status = e_block_pack_status::BLK_FAILED_FEASIBLE;
12051205
break; /* no more candidate primitives available, this molecule will not pack, return fail */
@@ -1392,7 +1392,6 @@ ClusterLegalizer::start_new_cluster(t_pack_molecule* molecule,
13921392
!molecule_cluster[molecule].is_valid());
13931393
// Safety asserts to ensure that the API was initialized properly.
13941394
VTR_ASSERT_SAFE(cluster_placement_stats != nullptr &&
1395-
primitives_list != nullptr &&
13961395
lb_type_rr_graphs != nullptr);
13971396

13981397
const AtomContext& atom_ctx = g_vpr_ctx.atom();
@@ -1465,7 +1464,6 @@ e_block_pack_status ClusterLegalizer::add_mol_to_cluster(t_pack_molecule* molecu
14651464
!molecule_cluster[molecule].is_valid());
14661465
// Safety asserts to ensure that the API was initialized properly.
14671466
VTR_ASSERT_SAFE(cluster_placement_stats != nullptr &&
1468-
primitives_list != nullptr &&
14691467
lb_type_rr_graphs != nullptr);
14701468

14711469
// Get the cluster.
@@ -1570,25 +1568,16 @@ ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
15701568
ClusterLegalizationStrategy t_cluster_legalization_strategy,
15711569
bool t_enable_pin_feasibility_filter,
15721570
int t_feasible_block_array_size,
1573-
int t_log_verbosity,
1574-
int t_force_site) : prepacker(t_prepacker) {
1575-
// Ensure that this is not being initialized twice.
1576-
VTR_ASSERT(cluster_placement_stats == nullptr &&
1577-
primitives_list == nullptr &&
1578-
lb_type_rr_graphs == nullptr);
1571+
int t_log_verbosity) : prepacker(t_prepacker) {
15791572
// Verify that the inputs are valid.
15801573
VTR_ASSERT(t_lb_type_rr_graphs != nullptr);
15811574

15821575
// Resize the atom_cluster lookup to make the accesses much cheaper.
15831576
atom_cluster.resize(atom_netlist.blocks().size(), LegalizationClusterId::INVALID());
15841577
// Allocate the cluster_placement_stats
15851578
cluster_placement_stats = alloc_and_load_cluster_placement_stats();
1586-
// Allocate the primitives_lists
1587-
size_t max_molecule_size = prepacker.get_max_molecule_size();
1588-
primitives_list = new t_pb_graph_node*[max_molecule_size];
1589-
for (size_t i = 0; i < max_molecule_size; i++) {
1590-
primitives_list[i] = nullptr;
1591-
}
1579+
// Pre-compute the max size of any molecule.
1580+
max_molecule_size = prepacker.get_max_molecule_size();
15921581
// Calculate the max cluster size
15931582
// - Limit maximum number of elements for each cluster to MAX_SHORT
15941583
max_cluster_size = calc_max_cluster_size(logical_block_types);
@@ -1608,7 +1597,6 @@ ClusterLegalizer::ClusterLegalizer(const AtomNetlist& atom_netlist,
16081597
enable_pin_feasibility_filter = t_enable_pin_feasibility_filter;
16091598
feasible_block_array_size = t_feasible_block_array_size;
16101599
log_verbosity = t_log_verbosity;
1611-
force_site = t_force_site;
16121600
// Get the target external pin utilization
16131601
// NOTE: This is really silly, but this can potentially fail. If it does
16141602
// it is important that everything is allocated. If not, when it fails
@@ -1714,24 +1702,9 @@ void ClusterLegalizer::finalize() {
17141702
}
17151703

17161704
ClusterLegalizer::~ClusterLegalizer() {
1717-
// Protect against double freeing.
1718-
// TODO: This may be able to be done better if this class had some flag
1719-
// to indicate if it has been initialized or not.
1720-
if (primitives_list == nullptr) {
1721-
// Ensure that all of the allocated structures are nullptr.
1722-
VTR_ASSERT(cluster_placement_stats == nullptr &&
1723-
primitives_list == nullptr &&
1724-
lb_type_rr_graphs == nullptr);
1725-
return;
1726-
}
1727-
VTR_ASSERT(cluster_placement_stats != nullptr &&
1728-
primitives_list != nullptr &&
1729-
lb_type_rr_graphs != nullptr);
17301705
// Reset. This is necessary to free the data within the clusters themselves.
17311706
reset();
17321707
// Free the cluster_placement_stats
17331708
free_cluster_placement_stats(cluster_placement_stats);
1734-
// Free the primitives_list
1735-
delete[] primitives_list;
17361709
}
17371710

0 commit comments

Comments
 (0)