@@ -36,6 +36,51 @@ void set_placer_breakpoint_reached(bool flag) {
36
36
f_placer_breakpoint_reached = flag;
37
37
}
38
38
39
+ /* *
40
+ * @brief Expand the y-axis search range based on the number of blocks in the column
41
+ *
42
+ * @param search_range The search range to adjust
43
+ * @param y_lower_iter The lower bound of the search range in the compressed grid
44
+ * @param y_range The search range across the y-axis
45
+ * @param type The type of the block to move
46
+ * @param block_rows Compatible blocks in the column
47
+ */
48
+ static void adjust_y_axis_search_range (t_bb& search_range,
49
+ vtr::flat_map2<int , t_physical_tile_loc>::const_iterator& y_lower_iter,
50
+ int & y_range,
51
+ t_logical_block_type_ptr type,
52
+ const vtr::flat_map2<int , t_physical_tile_loc>& block_rows) {
53
+
54
+ auto y_upper_iter = block_rows.upper_bound (search_range.ymax );
55
+
56
+ if (block_rows.size () > G_MIN_NUM_BLOCKS_IN_COLUMN) {
57
+ if (y_lower_iter->first > search_range.ymin ) {
58
+ // No valid blocks at this x location which are within rlim_y
59
+ //
60
+ if (type->index != 1 ) {
61
+ continue ;
62
+ } else {
63
+ // Fall back to allow the whole y range
64
+ y_lower_iter = block_rows.begin ();
65
+ y_upper_iter = block_rows.end ();
66
+
67
+ search_range.ymin = y_lower_iter->first ;
68
+ search_range.ymax = (y_upper_iter - 1 )->first ;
69
+ }
70
+ }
71
+ } else { // search_range is not fixed and there are less than G_MIN_NUM_BLOCKS_IN_COLUMN blocks at this x location
72
+ y_lower_iter = block_rows.begin ();
73
+ y_upper_iter = block_rows.end ();
74
+
75
+ search_range.ymin = y_lower_iter->first ;
76
+ search_range.ymax = (y_upper_iter - 1 )->first ;
77
+ }
78
+
79
+ y_range = std::distance (y_lower_iter, y_upper_iter);
80
+
81
+ return y_lower_iter;
82
+ }
83
+
39
84
e_create_move create_move (t_pl_blocks_to_be_moved& blocks_affected,
40
85
ClusterBlockId b_from,
41
86
t_pl_loc to,
@@ -680,7 +725,8 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
680
725
t_physical_tile_loc to_compressed_loc;
681
726
bool legal = false ;
682
727
683
- if (is_cluster_constrained (b_from)) {
728
+ bool cluster_constrained = is_cluster_constrained (b_from);
729
+ if (cluster_constrained) {
684
730
bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
685
731
search_range,
686
732
delta_cx,
@@ -699,7 +745,8 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
699
745
to_layer_num,
700
746
/* search_for_empty=*/ false ,
701
747
blk_loc_registry,
702
- rng);
748
+ rng,
749
+ cluster_constrained);
703
750
704
751
if (!legal) {
705
752
// No valid position found
@@ -772,7 +819,8 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
772
819
t_physical_tile_loc to_compressed_loc;
773
820
bool legal = false ;
774
821
775
- if (is_cluster_constrained (b_from)) {
822
+ bool cluster_constrained = is_cluster_constrained (b_from);
823
+ if (cluster_constrained) {
776
824
bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
777
825
search_range,
778
826
delta_cx,
@@ -791,7 +839,8 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
791
839
to_layer_num,
792
840
/* search_for_empty=*/ false ,
793
841
blk_loc_registry,
794
- rng);
842
+ rng,
843
+ cluster_constrained);
795
844
796
845
if (!legal) {
797
846
// No valid position found
@@ -861,7 +910,8 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
861
910
t_physical_tile_loc to_compressed_loc;
862
911
bool legal = false ;
863
912
864
- if (is_cluster_constrained (b_from)) {
913
+ bool cluster_constrained = is_cluster_constrained (b_from);
914
+ if (cluster_constrained) {
865
915
bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
866
916
search_range,
867
917
delta_cx,
@@ -871,7 +921,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
871
921
}
872
922
}
873
923
874
- // TODO: For now, we only move the blocks on the same tile
924
+ // TODO: For now, we only move the blocks on the same layer
875
925
legal = find_compatible_compressed_loc_in_range (blk_type,
876
926
delta_cx,
877
927
from_compressed_loc[to_layer_num],
@@ -881,7 +931,8 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
881
931
to_layer_num,
882
932
/* search_for_empty=*/ false ,
883
933
blk_loc_registry,
884
- rng);
934
+ rng,
935
+ cluster_constrained);
885
936
886
937
if (!legal) {
887
938
// No valid position found
@@ -975,7 +1026,8 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
975
1026
int to_layer_num,
976
1027
bool search_for_empty,
977
1028
const BlkLocRegistry& blk_loc_registry,
978
- vtr::RngContainer& rng) {
1029
+ vtr::RngContainer& rng,
1030
+ bool fixed_search_range) {
979
1031
// TODO For the time being, the blocks only moved in the same layer. This assertion should be removed after VPR is updated to move blocks between layers
980
1032
VTR_ASSERT (to_layer_num == from_loc.layer_num );
981
1033
const auto & compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [type->index ];
@@ -1010,39 +1062,16 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
1010
1062
// The candidates are stored in a flat_map so we can efficiently find the set of valid
1011
1063
// candidates with upper/lower bound.
1012
1064
const auto & block_rows = compressed_block_grid.get_column_block_map (to_loc.x , to_layer_num);
1013
- auto y_lower_iter = block_rows.begin ();
1014
- auto y_upper_iter = block_rows.end ();
1015
-
1016
- if (block_rows.size () > G_MIN_NUM_BLOCKS_IN_COLUMN || search_range.is_fixed ) {
1017
- y_lower_iter = block_rows.lower_bound (search_range.ymin );
1018
- if (y_lower_iter == block_rows.end ()) {
1019
- continue ;
1020
- }
1021
- y_upper_iter = block_rows.upper_bound (search_range.ymax );
1022
-
1023
- if (y_lower_iter->first > search_range.ymin ) {
1024
- // No valid blocks at this x location which are within rlim_y
1025
- //
1026
- if (type->index != 1 ) {
1027
- continue ;
1028
- } else if (!search_range.is_fixed ) {
1029
- // Fall back to allow the whole y range
1030
- y_lower_iter = block_rows.begin ();
1031
- y_upper_iter = block_rows.end ();
1032
-
1033
- search_range.ymin = y_lower_iter->first ;
1034
- search_range.ymax = (y_upper_iter - 1 )->first ;
1035
- }
1036
- }
1037
- } else { // search_range is not fixed and there are less than G_MIN_NUM_BLOCKS_IN_COLUMN blocks at this x location
1038
- y_lower_iter = block_rows.begin ();
1039
- y_upper_iter = block_rows.end ();
1040
-
1041
- search_range.ymin = y_lower_iter->first ;
1042
- search_range.ymax = (y_upper_iter - 1 )->first ;
1065
+ auto y_lower_iter = block_rows.lower_bound (search_range.ymin );
1066
+ auto y_upper_iter = block_rows.upper_bound (search_range.ymax );
1067
+ if (y_lower_iter == block_rows.end ()) {
1068
+ continue ;
1043
1069
}
1044
-
1045
1070
int y_range = std::distance (y_lower_iter, y_upper_iter);
1071
+ if (!fixed_search_range) {
1072
+ y_lower_iter = adjust_y_axis_search_range (search_range, y_range, type, block_rows);
1073
+ }
1074
+
1046
1075
VTR_ASSERT (y_range >= 0 );
1047
1076
1048
1077
// At this point we know y_lower_iter and y_upper_iter
0 commit comments