Skip to content

Commit f9e8517

Browse files
committed
[vpr][place] remove adjust search range and adjust it inside find_compatible_compressed_loc_in_range
1 parent fe99d5e commit f9e8517

File tree

3 files changed

+46
-61
lines changed

3 files changed

+46
-61
lines changed

vpr/src/place/initial_placement.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
440440
/*is_median=*/false,
441441
centroid_loc_layer_num,
442442
search_for_empty,
443+
/*block_constrained=*/false,
443444
blk_loc_registry,
444445
rng);
445446

@@ -1075,6 +1076,7 @@ bool try_place_macro_randomly(const t_pl_macro& pl_macro,
10751076
/*is_median=*/false,
10761077
selected_layer,
10771078
/*search_for_empty=*/false,
1079+
/*block_constrained=*/false,
10781080
blk_loc_registry,
10791081
rng);
10801082

vpr/src/place/move_utils.cpp

+42-60
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,6 @@ void set_placer_breakpoint_reached(bool flag) {
2828
f_placer_breakpoint_reached = flag;
2929
}
3030

31-
/**
32-
* @brief Adjust the search range based on the block type and constraints
33-
*
34-
* If the block is an IO block, we expand the search range to include all blocks in the column
35-
* We found empirically that this is a good strategy for IO blocks given they are located in
36-
* the periphery for most FPGA architectures
37-
*
38-
* @param block_type The type of the block to move
39-
* @param block_id The block ID of the moving block
40-
* @param search_range The search range to adjust
41-
* @param delta_cx The delta x of the search range
42-
* @param to_layer_num The layer that the block is moving to
43-
*
44-
* @return true if the search range was adjusted, false otherwise
45-
*/
46-
static bool adjust_search_range(t_logical_block_type_ptr block_type,
47-
ClusterBlockId block_id,
48-
t_bb& search_range,
49-
int& delta_cx,
50-
int to_layer_num) {
51-
52-
auto block_constrained = is_cluster_constrained(block_id);
53-
54-
if (block_constrained) {
55-
bool intersect = intersect_range_limit_with_floorplan_constraints(block_id,
56-
search_range,
57-
delta_cx,
58-
to_layer_num);
59-
if (!intersect) {
60-
return false;
61-
}
62-
}
63-
64-
if (is_io_type(block_type) && !block_constrained) {
65-
/* We empirically found that for the IO blocks,
66-
* Given their sparsity, we expand the y-axis search range
67-
* to include all blocks in the column
68-
*/
69-
const t_compressed_block_grid& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
70-
search_range.ymin = 0;
71-
search_range.ymax = compressed_block_grid.get_num_rows(to_layer_num) - 1;
72-
}
73-
74-
return true;
75-
}
76-
7731
e_create_move create_move(t_pl_blocks_to_be_moved& blocks_affected,
7832
ClusterBlockId b_from,
7933
t_pl_loc to,
@@ -715,9 +669,16 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
715669
rlim);
716670
int delta_cx = search_range.xmax - search_range.xmin;
717671

718-
bool adjust_search_range_res = adjust_search_range(type, b_from, search_range, delta_cx, to_layer_num);
719-
if (!adjust_search_range_res) {
720-
return false;
672+
auto block_constrained = is_cluster_constrained(b_from);
673+
674+
if (block_constrained) {
675+
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
676+
search_range,
677+
delta_cx,
678+
to_layer_num);
679+
if (!intersect) {
680+
return false;
681+
}
721682
}
722683

723684
t_physical_tile_loc to_compressed_loc;
@@ -731,6 +692,7 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
731692
/*is_median=*/false,
732693
to_layer_num,
733694
/*search_for_empty=*/false,
695+
block_constrained,
734696
blk_loc_registry,
735697
rng);
736698

@@ -802,9 +764,16 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
802764
to_layer_num,
803765
to_layer_num);
804766

805-
bool adjust_search_range_res = adjust_search_range(blk_type, b_from, search_range, delta_cx, to_layer_num);
806-
if (!adjust_search_range_res) {
807-
return false;
767+
auto block_constrained = is_cluster_constrained(b_from);
768+
769+
if (block_constrained) {
770+
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
771+
search_range,
772+
delta_cx,
773+
to_layer_num);
774+
if (!intersect) {
775+
return false;
776+
}
808777
}
809778

810779
t_physical_tile_loc to_compressed_loc;
@@ -817,6 +786,7 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
817786
/*is_median=*/true,
818787
to_layer_num,
819788
/*search_for_empty=*/false,
789+
block_constrained,
820790
blk_loc_registry,
821791
rng);
822792

@@ -885,9 +855,16 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
885855
}
886856
delta_cx = search_range.xmax - search_range.xmin;
887857

888-
bool adjust_search_range_res = adjust_search_range(blk_type, b_from, search_range, delta_cx, to_layer_num);
889-
if (!adjust_search_range_res) {
890-
return false;
858+
auto block_constrained = is_cluster_constrained(b_from);
859+
860+
if (block_constrained) {
861+
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
862+
search_range,
863+
delta_cx,
864+
to_layer_num);
865+
if (!intersect) {
866+
return false;
867+
}
891868
}
892869

893870
t_physical_tile_loc to_compressed_loc;
@@ -902,6 +879,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
902879
/*is_median=*/false,
903880
to_layer_num,
904881
/*search_for_empty=*/false,
882+
block_constrained,
905883
blk_loc_registry,
906884
rng);
907885

@@ -991,11 +969,12 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
991969
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
992970
const int delta_cx,
993971
const t_physical_tile_loc& from_loc,
994-
const t_bb& search_range,
972+
t_bb search_range,
995973
t_physical_tile_loc& to_loc,
996974
bool is_median,
997975
int to_layer_num,
998976
bool search_for_empty,
977+
bool block_constrained,
999978
const BlkLocRegistry& blk_loc_registry,
1000979
vtr::RngContainer& rng) {
1001980
//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
@@ -1038,10 +1017,13 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
10381017
}
10391018
auto y_upper_iter = block_rows.upper_bound(search_range.ymax);
10401019

1041-
if (y_lower_iter->first > search_range.ymin) {
1042-
if (!is_io_type(type)) {
1043-
continue;
1044-
}
1020+
if (block_rows.size() < 3) {
1021+
//Fall back to allow the whole y range
1022+
y_lower_iter = block_rows.begin();
1023+
y_upper_iter = block_rows.end();
1024+
1025+
search_range.ymin = y_lower_iter->first;
1026+
search_range.ymax = (y_upper_iter - 1)->first;
10451027
}
10461028

10471029
int y_range = std::distance(y_lower_iter, y_upper_iter);

vpr/src/place/move_utils.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,12 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
333333
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
334334
int delta_cx,
335335
const t_physical_tile_loc& from_loc,
336-
const t_bb& search_range,
336+
t_bb search_range,
337337
t_physical_tile_loc& to_loc,
338338
bool is_median,
339339
int to_layer_num,
340340
bool search_for_empty,
341+
bool block_constrained,
341342
const BlkLocRegistry& blk_loc_registry,
342343
vtr::RngContainer& rng);
343344

0 commit comments

Comments
 (0)