@@ -126,6 +126,7 @@ ClusterGainStats GreedyCandidateSelector::create_cluster_gain_stats(
126
126
ClusterGainStats cluster_gain_stats;
127
127
cluster_gain_stats.initial_search_for_feasible_blocks = true ;
128
128
cluster_gain_stats.num_search_for_feasible_blocks_occured = 0 ;
129
+ cluster_gain_stats.num_search_for_feasible_blocks_occurred_limit = packer_opts_.feasible_block_array_size ;
129
130
cluster_gain_stats.feasible_blocks .clear ();
130
131
cluster_gain_stats.tie_break_high_fanout_net = AtomNetId::INVALID ();
131
132
cluster_gain_stats.explore_transitive_fanout = true ;
@@ -602,14 +603,26 @@ t_pack_molecule* GreedyCandidateSelector::get_next_candidate_for_cluster(
602
603
t_pack_molecule* best_molecule = nullptr ;
603
604
// checking if there are feasible blocks being proposed
604
605
// checking if number of suggestion reached the limit
605
- if (cluster_gain_stats.feasible_blocks .size () > 0 && cluster_gain_stats.num_search_for_feasible_blocks_occured < packer_opts_. feasible_block_array_size ) {
606
+ if (cluster_gain_stats.feasible_blocks .size () > 0 && cluster_gain_stats.num_search_for_feasible_blocks_occured < cluster_gain_stats. num_search_for_feasible_blocks_occurred_limit ) {
606
607
best_molecule = cluster_gain_stats.feasible_blocks .pop ().first ;
607
608
if (best_molecule != nullptr ) {
608
609
cluster_gain_stats.num_search_for_feasible_blocks_occured ++;
609
610
VTR_ASSERT (!cluster_legalizer.is_mol_clustered (best_molecule));
610
611
}
611
612
}
612
613
614
+ // If we have no feasible blocks, or we have reached the limit of number of pops,
615
+ // then we need to clear the feasible blocks list and reset the number of pops.
616
+ // This ensures that we can continue searching for feasible blocks for the remaining
617
+ // steps (2.transitive, 3.high fanout, 4.attraction group).
618
+ if (cluster_gain_stats.feasible_blocks .size () == 0 ||
619
+ cluster_gain_stats.num_search_for_feasible_blocks_occured >= cluster_gain_stats.num_search_for_feasible_blocks_occurred_limit ||
620
+ cluster_gain_stats.feasible_blocks .delete_pending_set .size () == cluster_gain_stats.feasible_blocks .content_set .size ()
621
+ ){
622
+ cluster_gain_stats.feasible_blocks .clear ();
623
+ cluster_gain_stats.num_search_for_feasible_blocks_occured = 0 ;
624
+ }
625
+
613
626
// If we are allowing unrelated clustering and no molecule has been found,
614
627
// get unrelated candidate for cluster.
615
628
if (allow_unrelated_clustering_ && best_molecule == nullptr ) {
@@ -1032,22 +1045,6 @@ void GreedyCandidateSelector::update_candidate_selector_finalize_cluster(
1032
1045
}
1033
1046
}
1034
1047
1035
- template <typename T_key, typename T_sort>
1036
- LazyPopUniquePriorityQueue<T_key, T_sort>::LazyPopUniquePriorityQueue() {
1037
- // Initialize the priority queue
1038
- heap.clear ();
1039
- content_set.clear ();
1040
- delete_pending_set.clear ();
1041
- }
1042
-
1043
- template <typename T_key, typename T_sort>
1044
- LazyPopUniquePriorityQueue<T_key, T_sort>::~LazyPopUniquePriorityQueue () {
1045
- // Clear the priority queue
1046
- heap.clear ();
1047
- content_set.clear ();
1048
- delete_pending_set.clear ();
1049
- }
1050
-
1051
1048
template <typename T_key, typename T_sort>
1052
1049
void LazyPopUniquePriorityQueue<T_key, T_sort>::push(T_key key, T_sort value){
1053
1050
// Insert the key and sort value pair into the queue if it is not already present
@@ -1061,6 +1058,7 @@ void LazyPopUniquePriorityQueue<T_key, T_sort>::push(T_key key, T_sort value){
1061
1058
LazyPopUniquePriorityQueueCompare ());
1062
1059
content_set.insert (key);
1063
1060
}
1061
+
1064
1062
template <typename T_key, typename T_sort>
1065
1063
std::pair<T_key,T_sort> LazyPopUniquePriorityQueue<T_key, T_sort>::pop(){
1066
1064
std::pair<T_key, T_sort> top_pair;
@@ -1085,14 +1083,6 @@ std::pair<T_key,T_sort> LazyPopUniquePriorityQueue<T_key, T_sort>::pop(){
1085
1083
return top_pair;
1086
1084
}
1087
1085
1088
- template <typename T_key, typename T_sort>
1089
- void LazyPopUniquePriorityQueue<T_key, T_sort>::clear() {
1090
- // Clear the priority queue
1091
- heap.clear ();
1092
- content_set.clear ();
1093
- delete_pending_set.clear ();
1094
- }
1095
-
1096
1086
template <typename T_key, typename T_sort>
1097
1087
void LazyPopUniquePriorityQueue<T_key, T_sort>::remove(T_key key) {
1098
1088
// If the key is in the priority queue, remove it from the heap and reheapify
@@ -1119,18 +1109,3 @@ void LazyPopUniquePriorityQueue<T_key, T_sort>::remove_at_pop_time(T_key key) {
1119
1109
}
1120
1110
}
1121
1111
1122
- template <typename T_key, typename T_sort>
1123
- bool LazyPopUniquePriorityQueue<T_key, T_sort>::empty() {
1124
- return heap.empty ();
1125
- }
1126
-
1127
- template <typename T_key, typename T_sort>
1128
- size_t LazyPopUniquePriorityQueue<T_key, T_sort>::size() {
1129
- return heap.size ();
1130
- }
1131
-
1132
- template <typename T_key, typename T_sort>
1133
- bool LazyPopUniquePriorityQueue<T_key, T_sort>::contains(T_key key) {
1134
- return content_set.find (key) != content_set.end ();
1135
- }
1136
-
0 commit comments