16
16
// Note: The flag is only effective if compiled with VTR_ENABLE_DEBUG_LOGGING
17
17
bool f_placer_breakpoint_reached = false ;
18
18
19
+
20
+ /* *
21
+ * @brief Adjust the search range based on how many blocks are in the column.
22
+ * If the number of blocks in the column is less than MIN_NUM_BLOCKS_IN_COLUMN,
23
+ * expand the search range to cover the entire column.
24
+ *
25
+ * @param block_type The type of the block to move
26
+ * @param compressed_column_num The compressed column to move the block to
27
+ * @param to_layer_num The layer that the block is moving to
28
+ * @param is_range_fixed Whether the search range is fixed (e.g., in case of placement constraints)
29
+ * @param search_range The search range to adjust
30
+ *
31
+ */
32
+ static void adjust_search_range (t_logical_block_type_ptr block_type,
33
+ const int compressed_column_num,
34
+ const int to_layer_num,
35
+ const bool is_range_fixed,
36
+ t_bb& search_range);
37
+
19
38
// Accessor for f_placer_breakpoint_reached
20
39
bool placer_breakpoint_reached () {
21
40
return f_placer_breakpoint_reached;
@@ -666,9 +685,17 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
666
685
rlim);
667
686
int delta_cx = search_range.xmax - search_range.xmin ;
668
687
669
- bool adjust_search_range_res = adjust_search_range (type, b_from, search_range, delta_cx, to_layer_num);
670
- if (!adjust_search_range_res) {
671
- return false ;
688
+
689
+ auto block_constrained = is_cluster_constrained (block_id);
690
+
691
+ if (block_constrained) {
692
+ bool intersect = intersect_range_limit_with_floorplan_constraints (block_id,
693
+ search_range,
694
+ delta_cx,
695
+ to_layer_num);
696
+ if (!intersect) {
697
+ return false ;
698
+ }
672
699
}
673
700
674
701
t_physical_tile_loc to_compressed_loc;
@@ -683,7 +710,8 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
683
710
to_layer_num,
684
711
/* search_for_empty=*/ false ,
685
712
blk_loc_registry,
686
- rng);
713
+ rng,
714
+ block_constrained);
687
715
688
716
if (!legal) {
689
717
// No valid position found
@@ -753,9 +781,16 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
753
781
to_layer_num,
754
782
to_layer_num);
755
783
756
- bool adjust_search_range_res = adjust_search_range (blk_type, b_from, search_range, delta_cx, to_layer_num);
757
- if (!adjust_search_range_res) {
758
- return false ;
784
+ auto block_constrained = is_cluster_constrained (b_from);
785
+
786
+ if (block_constrained) {
787
+ bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
788
+ search_range,
789
+ delta_cx,
790
+ to_layer_num);
791
+ if (!intersect) {
792
+ return false ;
793
+ }
759
794
}
760
795
761
796
t_physical_tile_loc to_compressed_loc;
@@ -769,7 +804,8 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
769
804
to_layer_num,
770
805
/* search_for_empty=*/ false ,
771
806
blk_loc_registry,
772
- rng);
807
+ rng,
808
+ block_constrained);
773
809
774
810
if (!legal) {
775
811
// No valid position found
@@ -836,9 +872,16 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
836
872
}
837
873
delta_cx = search_range.xmax - search_range.xmin ;
838
874
839
- bool adjust_search_range_res = adjust_search_range (blk_type, b_from, search_range, delta_cx, to_layer_num);
840
- if (!adjust_search_range_res) {
841
- return false ;
875
+ auto block_constrained = is_cluster_constrained (b_from);
876
+
877
+ if (block_constrained) {
878
+ bool intersect = intersect_range_limit_with_floorplan_constraints (b_from,
879
+ search_range,
880
+ delta_cx,
881
+ to_layer_num);
882
+ if (!intersect) {
883
+ return false ;
884
+ }
842
885
}
843
886
844
887
t_physical_tile_loc to_compressed_loc;
@@ -854,7 +897,8 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
854
897
to_layer_num,
855
898
/* search_for_empty=*/ false ,
856
899
blk_loc_registry,
857
- rng);
900
+ rng,
901
+ block_constrained);
858
902
859
903
if (!legal) {
860
904
// No valid position found
@@ -948,7 +992,8 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
948
992
int to_layer_num,
949
993
bool search_for_empty,
950
994
const BlkLocRegistry& blk_loc_registry,
951
- vtr::RngContainer& rng) {
995
+ vtr::RngContainer& rng,
996
+ const bool is_range_fixed) {
952
997
// 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
953
998
VTR_ASSERT (to_layer_num == from_loc.layer_num );
954
999
const auto & compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [type->index ];
@@ -983,6 +1028,11 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
983
1028
// The candidates are stored in a flat_map so we can efficiently find the set of valid
984
1029
// candidates with upper/lower bound.
985
1030
const auto & block_rows = compressed_block_grid.get_column_block_map (to_loc.x , to_layer_num);
1031
+ adjust_search_range (type,
1032
+ to_loc.x ,
1033
+ to_layer_num,
1034
+ is_range_fixed,
1035
+ search_range);
986
1036
auto y_lower_iter = block_rows.lower_bound (search_range.ymin );
987
1037
if (y_lower_iter == block_rows.end ()) {
988
1038
continue ;
@@ -1167,30 +1217,20 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
1167
1217
return true ;
1168
1218
}
1169
1219
1170
- bool adjust_search_range (t_logical_block_type_ptr block_type,
1171
- ClusterBlockId block_id,
1172
- t_bb& search_range,
1173
- int & delta_cx,
1174
- int to_layer_num) {
1220
+ static void adjust_search_range (t_logical_block_type_ptr block_type,
1221
+ const int compressed_column_num,
1222
+ const int to_layer_num,
1223
+ const bool is_range_fixed,
1224
+ t_bb& search_range) {
1225
+ // The value is chosen empirically to expand the search range for sparse blocks,
1226
+ // or blocks located on the perimeter of the FPGA (e.g., IO blocks)
1227
+ constexpr int MIN_NUM_BLOCKS_IN_COLUMN = 3 ;
1175
1228
1176
- auto block_constrained = is_cluster_constrained (block_id) ;
1229
+ const auto & compressed_block_grid = g_vpr_ctx. placement (). compressed_block_grids [block_type-> index ] ;
1177
1230
1178
- if (block_constrained) {
1179
- bool intersect = intersect_range_limit_with_floorplan_constraints (block_id,
1180
- search_range,
1181
- delta_cx,
1182
- to_layer_num);
1183
- if (!intersect) {
1184
- return false ;
1185
- }
1186
- }
1231
+ size_t num_blocks_in_column = compressed_block_grid.get_column_block_map (compressed_column_num, to_layer_num).size ();
1187
1232
1188
- if (block_type->is_io () && !block_constrained) {
1189
- /* We empirically found that for the IO blocks,
1190
- * Given their sparsity, we expand the y-axis search range
1191
- * to include all blocks in the column
1192
- */
1193
- const t_compressed_block_grid& compressed_block_grid = g_vpr_ctx.placement ().compressed_block_grids [block_type->index ];
1233
+ if (num_blocks_in_column < MIN_NUM_BLOCKS_IN_COLUMN && !is_range_fixed) {
1194
1234
search_range.ymin = 0 ;
1195
1235
search_range.ymax = compressed_block_grid.get_num_rows (to_layer_num) - 1 ;
1196
1236
}
0 commit comments