@@ -31,20 +31,20 @@ void set_placer_breakpoint_reached(bool flag) {
31
31
/* *
32
32
* @brief Adjust the search range based on the block type and constraints
33
33
*
34
+ * @param block_type The type of the block to move
34
35
* @param block_id The block ID of the moving block
35
36
* @param search_range The search range to adjust
36
37
* @param delta_cx The delta x of the search range
37
38
* @param to_layer_num The layer that the block is moving to
39
+ *
38
40
* @return true if the search range was adjusted, false otherwise
39
41
*/
40
- static bool adjust_search_range (ClusterBlockId block_id,
42
+ static bool adjust_search_range (t_logical_block_type_ptr block_type,
43
+ ClusterBlockId block_id,
41
44
t_bb& search_range,
42
45
int & delta_cx,
43
46
int to_layer_num) {
44
-
45
- const auto & device_ctx = g_vpr_ctx.device ();
46
-
47
- auto block_type = get_block_type (block_id);
47
+
48
48
auto block_constrained = is_cluster_constrained (block_id);
49
49
50
50
if (block_constrained) {
@@ -714,19 +714,13 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
714
714
rlim);
715
715
int delta_cx = search_range.xmax - search_range.xmin ;
716
716
717
+ bool adjust_search_range_res = adjust_search_range (type, b_from, search_range, delta_cx, to_layer_num);
718
+ if (!adjust_search_range_res) {
719
+ return false ;
720
+ }
721
+
717
722
t_physical_tile_loc to_compressed_loc;
718
723
bool legal = false ;
719
-
720
- bool cluster_constrained = is_cluster_constrained (b_from);
721
- if (cluster_constrained) {
722
- bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
723
- search_range,
724
- delta_cx,
725
- to_layer_num);
726
- if (!intersect) {
727
- return false ;
728
- }
729
- }
730
724
// TODO: For now, we only move the blocks on the same tile
731
725
legal = find_compatible_compressed_loc_in_range (type,
732
726
delta_cx,
@@ -737,8 +731,7 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
737
731
to_layer_num,
738
732
/* search_for_empty=*/ false ,
739
733
blk_loc_registry,
740
- rng,
741
- cluster_constrained);
734
+ rng);
742
735
743
736
if (!legal) {
744
737
// No valid position found
@@ -808,20 +801,13 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
808
801
to_layer_num,
809
802
to_layer_num);
810
803
811
- t_physical_tile_loc to_compressed_loc;
812
- bool legal = false ;
813
-
814
- bool cluster_constrained = is_cluster_constrained (b_from);
815
- if (cluster_constrained) {
816
- bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
817
- search_range,
818
- delta_cx,
819
- to_layer_num);
820
- if (!intersect) {
821
- return false ;
822
- }
804
+ bool adjust_search_range_res = adjust_search_range (blk_type, b_from, search_range, delta_cx, to_layer_num);
805
+ if (!adjust_search_range_res) {
806
+ return false ;
823
807
}
824
808
809
+ t_physical_tile_loc to_compressed_loc;
810
+ bool legal = false ;
825
811
legal = find_compatible_compressed_loc_in_range (blk_type,
826
812
delta_cx,
827
813
from_compressed_locs[to_layer_num],
@@ -831,8 +817,7 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
831
817
to_layer_num,
832
818
/* search_for_empty=*/ false ,
833
819
blk_loc_registry,
834
- rng,
835
- cluster_constrained);
820
+ rng);
836
821
837
822
if (!legal) {
838
823
// No valid position found
@@ -899,20 +884,14 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
899
884
}
900
885
delta_cx = search_range.xmax - search_range.xmin ;
901
886
887
+ bool adjust_search_range_res = adjust_search_range (blk_type, b_from, search_range, delta_cx, to_layer_num);
888
+ if (!adjust_search_range_res) {
889
+ return false ;
890
+ }
891
+
902
892
t_physical_tile_loc to_compressed_loc;
903
893
bool legal = false ;
904
894
905
- bool cluster_constrained = is_cluster_constrained (b_from);
906
- if (cluster_constrained) {
907
- bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
908
- search_range,
909
- delta_cx,
910
- to_layer_num);
911
- if (!intersect) {
912
- return false ;
913
- }
914
- }
915
-
916
895
// TODO: For now, we only move the blocks on the same layer
917
896
legal = find_compatible_compressed_loc_in_range (blk_type,
918
897
delta_cx,
@@ -923,8 +902,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
923
902
to_layer_num,
924
903
/* search_for_empty=*/ false ,
925
904
blk_loc_registry,
926
- rng,
927
- cluster_constrained);
905
+ rng);
928
906
929
907
if (!legal) {
930
908
// No valid position found
@@ -1012,14 +990,13 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
1012
990
bool find_compatible_compressed_loc_in_range (t_logical_block_type_ptr type,
1013
991
const int delta_cx,
1014
992
const t_physical_tile_loc& from_loc,
1015
- t_bb search_range,
993
+ const t_bb& search_range,
1016
994
t_physical_tile_loc& to_loc,
1017
995
bool is_median,
1018
996
int to_layer_num,
1019
997
bool search_for_empty,
1020
998
const BlkLocRegistry& blk_loc_registry,
1021
- vtr::RngContainer& rng,
1022
- bool fixed_search_range) {
999
+ vtr::RngContainer& rng) {
1023
1000
// 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
1024
1001
VTR_ASSERT (to_layer_num == from_loc.layer_num );
1025
1002
const auto & compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [type->index ];
@@ -1054,15 +1031,14 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
1054
1031
// The candidates are stored in a flat_map so we can efficiently find the set of valid
1055
1032
// candidates with upper/lower bound.
1056
1033
const auto & block_rows = compressed_block_grid.get_column_block_map (to_loc.x , to_layer_num);
1057
- if (!fixed_search_range) {
1058
- adjust_y_axis_search_range (search_range, block_rows);
1059
- }
1060
1034
auto y_lower_iter = block_rows.lower_bound (search_range.ymin );
1061
1035
if (y_lower_iter == block_rows.end ()) {
1062
1036
continue ;
1063
1037
}
1064
- y_lower_iter = block_rows.lower_bound (search_range.ymin );
1065
1038
auto y_upper_iter = block_rows.upper_bound (search_range.ymax );
1039
+ if (y_lower_iter->first > search_range.ymin ) {
1040
+ continue ;
1041
+ }
1066
1042
int y_range = std::distance (y_lower_iter, y_upper_iter);
1067
1043
VTR_ASSERT (y_range >= 0 );
1068
1044
0 commit comments