Skip to content

Commit f33dde9

Browse files
[ClusterLegalizer] Moved Stat Counting Into Cluster Legalizer
Found that one of the pb_stats members is required for cluster legalization; but was being calculated outside of the cluster legalizer. Moved this in to allow the cluster legalizer to be used outside of the clusterer. Also found an issue where two clusters of the same type cannot be constructed at the same time. Tried fixing it, but it produces different results (different clusters). Will raise in a separate PR, left as a fixme comment.
1 parent 143c29d commit f33dde9

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
499499
const AtomContext& atom_ctx = g_vpr_ctx.atom();
500500
AtomContext& mutable_atom_ctx = g_vpr_ctx.mutable_atom();
501501

502+
VTR_ASSERT_SAFE(cb != nullptr);
502503
e_block_pack_status block_pack_status = e_block_pack_status::BLK_PASSED;
503504

504505
/* Discover parent */
@@ -516,6 +517,7 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
516517
}
517518

518519
/* Create siblings if siblings are not allocated */
520+
VTR_ASSERT(parent_pb != nullptr);
519521
if (parent_pb->child_pbs == nullptr) {
520522
VTR_ASSERT(parent_pb->name == nullptr);
521523
parent_pb->name = vtr::strdup(atom_ctx.nlist.block_name(blk_id).c_str());
@@ -533,8 +535,8 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
533535
}
534536
}
535537
} else {
536-
/* if this is not the first child of this parent, must match existing parent mode */
537-
if (parent_pb->mode != pb_graph_node->pb_type->parent_mode->index) {
538+
/* if this is not the first child of this parent, must match existing parent mode */
539+
if (parent_pb->mode != pb_graph_node->pb_type->parent_mode->index) {
538540
return e_block_pack_status::BLK_FAILED_FEASIBLE;
539541
}
540542
}
@@ -548,6 +550,7 @@ try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
548550
}
549551
VTR_ASSERT(i < mode->num_pb_type_children);
550552
t_pb* pb = &parent_pb->child_pbs[i][pb_graph_node->placement_index];
553+
VTR_ASSERT_SAFE(pb != nullptr);
551554
*parent = pb; /* this pb is parent of it's child that called this function */
552555
VTR_ASSERT(pb->pb_graph_node == pb_graph_node);
553556
if (pb->pb_stats == nullptr) {
@@ -1364,6 +1367,15 @@ e_block_pack_status ClusterLegalizer::try_pack_molecule(t_pack_molecule* molecul
13641367
commit_primitive(cluster_placement_stats_ptr, primitives_list[i]);
13651368

13661369
atom_cluster_[atom_blk_id] = cluster_id;
1370+
1371+
// Update the num child blocks in pb
1372+
const t_pb* atom_pb = atom_ctx.lookup.atom_pb(atom_blk_id);
1373+
VTR_ASSERT_SAFE(atom_pb != nullptr);
1374+
t_pb* cur_pb = atom_pb->parent_pb;
1375+
while (cur_pb != nullptr) {
1376+
cur_pb->pb_stats->num_child_blocks_in_pb++;
1377+
cur_pb = cur_pb->parent_pb;
1378+
}
13671379
}
13681380

13691381
// Update the lookahead pins used.

vpr/src/pack/cluster_legalizer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@ class ClusterLegalizer {
416416

417417
/// @brief Stats keeper for placement information during packing/clustering.
418418
/// TODO: This should be a vector.
419+
/// FIXME: This keeps the stats for each cluster type. This is fine within
420+
/// the clusterer, however it yields a limitation where two clusters
421+
/// of the same type cannot be constructed at the same time. This
422+
/// should stored per cluster.
419423
t_cluster_placement_stats* cluster_placement_stats_ = nullptr;
420424

421425
/// @brief The utilization of external input/output pins during packing

vpr/src/pack/cluster_util.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,6 @@ void update_cluster_stats(const t_pack_molecule* molecule,
973973
cb = cur_pb;
974974
}
975975
cur_pb->pb_stats->num_feasible_blocks = NOT_VALID;
976-
cur_pb->pb_stats->num_child_blocks_in_pb++;
977976

978977
if (atom_grp_id != AttractGroupId::INVALID()) {
979978
/* TODO: Allow clusters to have more than one attraction group. */

0 commit comments

Comments
 (0)