Skip to content

Commit 1da6e6d

Browse files
committed
[vpr][place] add adjust_search_range
1 parent 512eb7c commit 1da6e6d

File tree

2 files changed

+30
-55
lines changed

2 files changed

+30
-55
lines changed

vpr/src/place/move_utils.cpp

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ void set_placer_breakpoint_reached(bool flag) {
3131
/**
3232
* @brief Adjust the search range based on the block type and constraints
3333
*
34+
* @param block_type The type of the block to move
3435
* @param block_id The block ID of the moving block
3536
* @param search_range The search range to adjust
3637
* @param delta_cx The delta x of the search range
3738
* @param to_layer_num The layer that the block is moving to
39+
*
3840
* @return true if the search range was adjusted, false otherwise
3941
*/
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,
4144
t_bb& search_range,
4245
int& delta_cx,
4346
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+
4848
auto block_constrained = is_cluster_constrained(block_id);
4949

5050
if (block_constrained) {
@@ -714,19 +714,13 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
714714
rlim);
715715
int delta_cx = search_range.xmax - search_range.xmin;
716716

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+
717722
t_physical_tile_loc to_compressed_loc;
718723
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-
}
730724
//TODO: For now, we only move the blocks on the same tile
731725
legal = find_compatible_compressed_loc_in_range(type,
732726
delta_cx,
@@ -737,8 +731,7 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
737731
to_layer_num,
738732
/*search_for_empty=*/false,
739733
blk_loc_registry,
740-
rng,
741-
cluster_constrained);
734+
rng);
742735

743736
if (!legal) {
744737
//No valid position found
@@ -808,20 +801,13 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
808801
to_layer_num,
809802
to_layer_num);
810803

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;
823807
}
824808

809+
t_physical_tile_loc to_compressed_loc;
810+
bool legal = false;
825811
legal = find_compatible_compressed_loc_in_range(blk_type,
826812
delta_cx,
827813
from_compressed_locs[to_layer_num],
@@ -831,8 +817,7 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
831817
to_layer_num,
832818
/*search_for_empty=*/false,
833819
blk_loc_registry,
834-
rng,
835-
cluster_constrained);
820+
rng);
836821

837822
if (!legal) {
838823
//No valid position found
@@ -899,20 +884,14 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
899884
}
900885
delta_cx = search_range.xmax - search_range.xmin;
901886

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+
902892
t_physical_tile_loc to_compressed_loc;
903893
bool legal = false;
904894

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-
916895
//TODO: For now, we only move the blocks on the same layer
917896
legal = find_compatible_compressed_loc_in_range(blk_type,
918897
delta_cx,
@@ -923,8 +902,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
923902
to_layer_num,
924903
/*search_for_empty=*/false,
925904
blk_loc_registry,
926-
rng,
927-
cluster_constrained);
905+
rng);
928906

929907
if (!legal) {
930908
//No valid position found
@@ -1012,14 +990,13 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
1012990
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
1013991
const int delta_cx,
1014992
const t_physical_tile_loc& from_loc,
1015-
t_bb search_range,
993+
const t_bb& search_range,
1016994
t_physical_tile_loc& to_loc,
1017995
bool is_median,
1018996
int to_layer_num,
1019997
bool search_for_empty,
1020998
const BlkLocRegistry& blk_loc_registry,
1021-
vtr::RngContainer& rng,
1022-
bool fixed_search_range) {
999+
vtr::RngContainer& rng) {
10231000
//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
10241001
VTR_ASSERT(to_layer_num == from_loc.layer_num);
10251002
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,
10541031
//The candidates are stored in a flat_map so we can efficiently find the set of valid
10551032
//candidates with upper/lower bound.
10561033
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-
}
10601034
auto y_lower_iter = block_rows.lower_bound(search_range.ymin);
10611035
if (y_lower_iter == block_rows.end()) {
10621036
continue;
10631037
}
1064-
y_lower_iter = block_rows.lower_bound(search_range.ymin);
10651038
auto y_upper_iter = block_rows.upper_bound(search_range.ymax);
1039+
if (y_lower_iter->first > search_range.ymin) {
1040+
continue;
1041+
}
10661042
int y_range = std::distance(y_lower_iter, y_upper_iter);
10671043
VTR_ASSERT(y_range >= 0);
10681044

vpr/src/place/move_utils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,14 +333,13 @@ 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,
341341
const BlkLocRegistry& blk_loc_registry,
342-
vtr::RngContainer& rng,
343-
bool fixed_search_range = false);
342+
vtr::RngContainer& rng);
344343

345344
/**
346345
* @brief Get the the compressed loc from the uncompressed loc (grid_loc)

0 commit comments

Comments
 (0)