Skip to content

Commit cfa8210

Browse files
committed
Revert "[vpr][place] remove adjust search range and adjust it inside find_compatible_compressed_loc_in_range"
This reverts commit f9e8517.
1 parent 4152246 commit cfa8210

File tree

3 files changed

+61
-46
lines changed

3 files changed

+61
-46
lines changed

vpr/src/place/initial_placement.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ 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,
444443
blk_loc_registry,
445444
rng);
446445

@@ -1076,7 +1075,6 @@ bool try_place_macro_randomly(const t_pl_macro& pl_macro,
10761075
/*is_median=*/false,
10771076
selected_layer,
10781077
/*search_for_empty=*/false,
1079-
/*block_constrained=*/false,
10801078
blk_loc_registry,
10811079
rng);
10821080

vpr/src/place/move_utils.cpp

+60-42
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,52 @@ 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+
3177
e_create_move create_move(t_pl_blocks_to_be_moved& blocks_affected,
3278
ClusterBlockId b_from,
3379
t_pl_loc to,
@@ -669,16 +715,9 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
669715
rlim);
670716
int delta_cx = search_range.xmax - search_range.xmin;
671717

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-
}
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;
682721
}
683722

684723
t_physical_tile_loc to_compressed_loc;
@@ -692,7 +731,6 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
692731
/*is_median=*/false,
693732
to_layer_num,
694733
/*search_for_empty=*/false,
695-
block_constrained,
696734
blk_loc_registry,
697735
rng);
698736

@@ -764,16 +802,9 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
764802
to_layer_num,
765803
to_layer_num);
766804

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-
}
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;
777808
}
778809

779810
t_physical_tile_loc to_compressed_loc;
@@ -786,7 +817,6 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
786817
/*is_median=*/true,
787818
to_layer_num,
788819
/*search_for_empty=*/false,
789-
block_constrained,
790820
blk_loc_registry,
791821
rng);
792822

@@ -855,16 +885,9 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
855885
}
856886
delta_cx = search_range.xmax - search_range.xmin;
857887

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-
}
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;
868891
}
869892

870893
t_physical_tile_loc to_compressed_loc;
@@ -879,7 +902,6 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
879902
/*is_median=*/false,
880903
to_layer_num,
881904
/*search_for_empty=*/false,
882-
block_constrained,
883905
blk_loc_registry,
884906
rng);
885907

@@ -969,12 +991,11 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
969991
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
970992
const int delta_cx,
971993
const t_physical_tile_loc& from_loc,
972-
t_bb search_range,
994+
const t_bb& search_range,
973995
t_physical_tile_loc& to_loc,
974996
bool is_median,
975997
int to_layer_num,
976998
bool search_for_empty,
977-
bool block_constrained,
978999
const BlkLocRegistry& blk_loc_registry,
9791000
vtr::RngContainer& rng) {
9801001
//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
@@ -1017,13 +1038,10 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
10171038
}
10181039
auto y_upper_iter = block_rows.upper_bound(search_range.ymax);
10191040

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;
1041+
if (y_lower_iter->first > search_range.ymin) {
1042+
if (!is_io_type(type)) {
1043+
continue;
1044+
}
10271045
}
10281046

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

vpr/src/place/move_utils.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,11 @@ 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-
t_bb search_range,
336+
const 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,
342341
const BlkLocRegistry& blk_loc_registry,
343342
vtr::RngContainer& rng);
344343

0 commit comments

Comments
 (0)