Skip to content

Commit 624f251

Browse files
Refactor is_atom_blk_in_pb function to get two t_pb* arguments
1 parent 4c61867 commit 624f251

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

vpr/src/pack/cluster_legalizer.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,18 +1771,6 @@ void ClusterLegalizer::finalize() {
17711771
}
17721772
}
17731773

1774-
bool ClusterLegalizer::is_atom_blk_in_cluster_block(const AtomBlockId blk_id, const AtomBlockId clustered_blk_id) const {
1775-
const t_pb* cur_pb = atom_pb_lookup().atom_pb(blk_id);
1776-
const t_pb* pb = atom_pb_lookup().atom_pb(clustered_blk_id);
1777-
while (cur_pb) {
1778-
if (cur_pb == pb) {
1779-
return true;
1780-
}
1781-
cur_pb = cur_pb->parent_pb;
1782-
}
1783-
return false;
1784-
}
1785-
17861774
ClusterLegalizer::~ClusterLegalizer() {
17871775
// Destroy all clusters (no need to compress).
17881776
for (LegalizationClusterId cluster_id : legalization_cluster_ids_) {

vpr/src/pack/cluster_legalizer.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@ class ClusterLegalizer {
514514
log_verbosity_ = verbosity;
515515
}
516516

517-
/*
518-
* @brief Determine if atom block is in cluster block.
519-
*
520-
*/
521-
bool is_atom_blk_in_cluster_block(const AtomBlockId blk_id, const AtomBlockId clustered_blk_id) const;
522-
523517
inline const AtomPBBimap &atom_pb_lookup() const {return atom_pb_lookup_;}
524518
inline AtomPBBimap &mutable_atom_pb_lookup() {return atom_pb_lookup_;}
525519

vpr/src/pack/greedy_candidate_selector.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,20 @@ void GreedyCandidateSelector::mark_and_update_partial_gain(
374374
cluster_gain_stats.num_pins_of_net_in_pb[net_id]++;
375375
}
376376

377+
/**
378+
* @brief Determine if pb is a child of cluster_pb.
379+
*/
380+
static bool is_pb_in_cluster_pb(const t_pb* pb, const t_pb* cluster_pb) {
381+
const t_pb* cur_pb = pb;
382+
while (cur_pb) {
383+
if (cur_pb == cluster_pb) {
384+
return true;
385+
}
386+
cur_pb = cur_pb->parent_pb;
387+
}
388+
return false;
389+
}
390+
377391
void GreedyCandidateSelector::update_connection_gain_values(
378392
ClusterGainStats& cluster_gain_stats,
379393
AtomNetId net_id,
@@ -394,8 +408,10 @@ void GreedyCandidateSelector::update_connection_gain_values(
394408
AtomBlockId blk_id = atom_netlist_.pin_block(pin_id);
395409
// TODO: Should investigate this. Using the atom pb bimap through is_atom_blk_in_cluster_block
396410
// in this class is very strange
397-
if (cluster_legalizer.get_atom_cluster(blk_id) == legalization_cluster_id
398-
&& cluster_legalizer.is_atom_blk_in_cluster_block(blk_id, clustered_blk_id)) {
411+
const t_pb *pin_block_pb = cluster_legalizer.atom_pb_lookup().atom_pb(blk_id);
412+
const t_pb *cluster_pb = cluster_legalizer.atom_pb_lookup().atom_pb(clustered_blk_id);
413+
414+
if (cluster_legalizer.get_atom_cluster(blk_id) == legalization_cluster_id && is_pb_in_cluster_pb(pin_block_pb, cluster_pb)) {
399415
num_internal_connections++;
400416
} else if (!cluster_legalizer.is_atom_clustered(blk_id)) {
401417
num_open_connections++;

0 commit comments

Comments
 (0)