Skip to content

[Place] Expand search range for sparse blocks #2960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0c355d8
[type] add is_fixed to t_bb
amin1377 Apr 1, 2025
42d06e7
[vpr][type] add comments for t_bb
amin1377 Apr 1, 2025
b80abb5
[place] expand search range if the number of blocks in the column is …
amin1377 Apr 1, 2025
0f038dc
make format
amin1377 Apr 1, 2025
271640b
[base][types] remove is_fixed from t_bb
amin1377 Apr 2, 2025
a2ae770
[vpr][place] adjust search range in another function
amin1377 Apr 2, 2025
01b55e8
[vpr][place] fix a typo
amin1377 Apr 2, 2025
df7a0c4
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Apr 3, 2025
75e9474
[vpr][place] fix a typo
amin1377 Apr 3, 2025
2e4dc59
[vpr][place] clean up the code
amin1377 Apr 3, 2025
34c7571
[vpr][place] don't continue if there is no compatible block in the gi…
amin1377 Apr 3, 2025
c94c8b8
[vpr][place] check lower_iter afer adjustment
amin1377 Apr 3, 2025
512eb7c
[vpr][place] add adjust_search_range
amin1377 Apr 3, 2025
1da6e6d
[vpr][place] add adjust_search_range
amin1377 Apr 3, 2025
a1d67f7
make format
amin1377 Apr 3, 2025
9c4057a
Merge branch 'master' into placement_search_range
amin1377 Apr 24, 2025
a27a74f
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 Apr 26, 2025
58a3522
[vpr][place] use is_io_type to determine whether a block is of the ty…
amin1377 Apr 26, 2025
43e33fa
[libs][libarch] add is_io_type for logical types
amin1377 Apr 26, 2025
3ea75f2
[vpr][place] add comment for adjust_search_range
amin1377 Apr 26, 2025
ac7a821
[test] update strong results
amin1377 Apr 26, 2025
6871fc9
[test] update srong odin
amin1377 Apr 26, 2025
84790cf
[test] update basic_timing results
amin1377 Apr 26, 2025
9f8e498
[test] update parmys and odin res
amin1377 Apr 26, 2025
e2b0c9d
[test] update nightly test 1 res
amin1377 Apr 28, 2025
cf86a33
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 1, 2025
a97d8db
[vpr][place] don't skip the x if search range min is below the y found
amin1377 May 1, 2025
2dc79c9
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 12, 2025
fe99d5e
[vpr][place] search for another column if block is not io and lower_b…
amin1377 May 13, 2025
f9e8517
[vpr][place] remove adjust search range and adjust it inside find_com…
amin1377 May 14, 2025
dae25cc
[vpr][place] use a constexpr to compare the number of blocks in column
amin1377 May 14, 2025
ade994b
[vpr][place] pass block_constraint parameter to relevant functions in…
amin1377 May 14, 2025
96e9cc5
make format
amin1377 May 14, 2025
4a6e333
[vpr][place] move MIN_BLK_PER_COLUMN_EXPAND into the routine
amin1377 May 14, 2025
caaf456
make format
amin1377 May 14, 2025
af29e9d
[vpr][place] expand search range if block is io
amin1377 May 14, 2025
7070d1b
Revert "[vpr][place] expand search range if block is io"
amin1377 May 14, 2025
7c96daa
Revert "make format"
amin1377 May 14, 2025
057d0a9
Revert "[vpr][place] move MIN_BLK_PER_COLUMN_EXPAND into the routine"
amin1377 May 14, 2025
8c4a49b
Revert "make format"
amin1377 May 14, 2025
d416295
Revert "[vpr][place] pass block_constraint parameter to relevant func…
amin1377 May 14, 2025
4152246
Revert "[vpr][place] use a constexpr to compare the number of blocks …
amin1377 May 14, 2025
cfa8210
Revert "[vpr][place] remove adjust search range and adjust it inside …
amin1377 May 14, 2025
17ec4a0
[vpr][place] move adjust_search_range to move_utils.h so it can be ac…
amin1377 May 14, 2025
5e8a495
[vpr][place] add adjust search range to find centriod neighbour
amin1377 May 14, 2025
36e1eb6
[vpr][place] remove a special case in find_compatible_compressed_loc_…
amin1377 May 15, 2025
59a08eb
Merge branch 'master' of https://github.com/verilog-to-routing/vtr-ve…
amin1377 May 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libs/libarchfpga/src/physical_types_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ bool is_io_type(t_physical_tile_type_ptr type) {
|| is_output_type(type);
}

bool is_io_type(t_logical_block_type_ptr type) {
auto physical_tile = pick_physical_type(type);
return is_io_type(physical_tile);
}

std::string block_type_pin_index_to_name(t_physical_tile_type_ptr type, int pin_physical_num, bool is_flat) {
int max_ptc = get_tile_pin_max_ptc(type, is_flat);
VTR_ASSERT(pin_physical_num < max_ptc);
Expand Down
3 changes: 3 additions & 0 deletions libs/libarchfpga/src/physical_types_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ bool is_output_type(t_physical_tile_type_ptr type);
///@brief Returns true if the given physical tile type can implement either a .input or .output block type
bool is_io_type(t_physical_tile_type_ptr type);

///@brief Returns true if the given logical block type is an IO block
bool is_io_type(t_logical_block_type_ptr type);

/**
* @brief Returns the corresponding physical pin based on the input parameters:
*
Expand Down
7 changes: 7 additions & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,13 @@ struct t_net_power {
/**
* @brief Stores a 3D bounding box in terms of the minimum and
* maximum coordinates: x, y, layer
*
* @var xmin: The minimum x-coordinate of the bounding box
* @var xmax: The maximum x-coordinate of the bounding box
* @var ymin: The minimum y-coordinate of the bounding box
* @var ymax: The maximum y-coordinate of the bounding box
* @var layer_min: The minimum layer of the bounding box
* @var layer_max: The maximum layer of the bounding box
*/
struct t_bb {
t_bb() = default;
Expand Down
29 changes: 22 additions & 7 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
*
* @return true if the function can find any location near the centroid one, false otherwise.
*/
static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
static bool find_centroid_neighbor(ClusterBlockId block_id,
t_pl_loc& centroid_loc,
t_logical_block_type_ptr block_type,
bool search_for_empty,
int r_lim,
Expand All @@ -212,7 +213,8 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,

/**
* @brief tries to place a macro at a centroid location of its placed connections.
*
*
* @param block_id The block to be placed.
* @param pl_macro The macro to be placed.
* @param pr The PartitionRegion of the macro - represents its floorplanning constraints, is the size of the whole chip if the macro is not
* constrained.
Expand All @@ -225,7 +227,8 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
*
* @return true if the macro gets placed, false if not.
*/
static bool try_centroid_placement(const t_pl_macro& pl_macro,
static bool try_centroid_placement(ClusterBlockId block_id,
const t_pl_macro& pl_macro,
const PartitionRegion& pr,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
Expand Down Expand Up @@ -400,7 +403,8 @@ bool find_subtile_in_location(t_pl_loc& centroid,
return false;
}

static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
static bool find_centroid_neighbor(ClusterBlockId block_id,
t_pl_loc& centroid_loc,
t_logical_block_type_ptr block_type,
bool search_for_empty,
int rlim,
Expand All @@ -425,6 +429,16 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,

int delta_cx = search_range.xmax - search_range.xmin;

bool search_range_adjusted = adjust_search_range(block_type,
block_id,
search_range,
delta_cx,
centroid_loc_layer_num);

if (!search_range_adjusted) {
return false;
}

//Block has not been placed yet, so the "from" coords will be (-1, -1)
int cx_from = OPEN;
int cy_from = OPEN;
Expand Down Expand Up @@ -832,7 +846,8 @@ static inline t_pl_loc find_nearest_compatible_loc(const t_flat_pl_loc& src_flat
return best_loc;
}

static bool try_centroid_placement(const t_pl_macro& pl_macro,
static bool try_centroid_placement(ClusterBlockId block_id,
const t_pl_macro& pl_macro,
const PartitionRegion& pr,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
Expand Down Expand Up @@ -889,7 +904,7 @@ static bool try_centroid_placement(const t_pl_macro& pl_macro,
//centroid suggestion was either occupied or does not match block type
//try to find a near location that meet these requirements
if (!found_legal_subtile) {
bool neighbor_legal_loc = find_centroid_neighbor(centroid_loc, block_type, false, rlim, blk_loc_registry, rng);
bool neighbor_legal_loc = find_centroid_neighbor(block_id, centroid_loc, block_type, false, rlim, blk_loc_registry, rng);
if (!neighbor_legal_loc) { //no neighbor candidate found
return false;
}
Expand Down Expand Up @@ -1300,7 +1315,7 @@ static bool place_macro(int macros_max_num_tries,

if (!macro_placed) {
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\t\tTry centroid placement\n");
macro_placed = try_centroid_placement(pl_macro, pr, block_type, pad_loc_type, block_scores, blk_loc_registry, flat_placement_info, rng);
macro_placed = try_centroid_placement(blk_id, pl_macro, pr, block_type, pad_loc_type, block_scores, blk_loc_registry, flat_placement_info, rng);
}
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\t\tMacro is placed: %d\n", macro_placed);
// If macro is not placed yet, try to place the macro randomly for the max number of random tries
Expand Down
97 changes: 48 additions & 49 deletions vpr/src/place/move_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,18 +669,13 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
rlim);
int delta_cx = search_range.xmax - search_range.xmin;

bool adjust_search_range_res = adjust_search_range(type, b_from, search_range, delta_cx, to_layer_num);
if (!adjust_search_range_res) {
return false;
}

t_physical_tile_loc to_compressed_loc;
bool legal = false;

if (is_cluster_constrained(b_from)) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
to_layer_num);
if (!intersect) {
return false;
}
}
//TODO: For now, we only move the blocks on the same tile
legal = find_compatible_compressed_loc_in_range(type,
delta_cx,
Expand Down Expand Up @@ -761,19 +756,13 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
to_layer_num,
to_layer_num);

t_physical_tile_loc to_compressed_loc;
bool legal = false;

if (is_cluster_constrained(b_from)) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
to_layer_num);
if (!intersect) {
return false;
}
bool adjust_search_range_res = adjust_search_range(blk_type, b_from, search_range, delta_cx, to_layer_num);
if (!adjust_search_range_res) {
return false;
}

t_physical_tile_loc to_compressed_loc;
bool legal = false;
legal = find_compatible_compressed_loc_in_range(blk_type,
delta_cx,
from_compressed_locs[to_layer_num],
Expand Down Expand Up @@ -850,20 +839,15 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
}
delta_cx = search_range.xmax - search_range.xmin;

bool adjust_search_range_res = adjust_search_range(blk_type, b_from, search_range, delta_cx, to_layer_num);
if (!adjust_search_range_res) {
return false;
}

t_physical_tile_loc to_compressed_loc;
bool legal = false;

if (is_cluster_constrained(b_from)) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
to_layer_num);
if (!intersect) {
return false;
}
}

//TODO: For now, we only move the blocks on the same tile
//TODO: For now, we only move the blocks on the same layer
legal = find_compatible_compressed_loc_in_range(blk_type,
delta_cx,
from_compressed_loc[to_layer_num],
Expand Down Expand Up @@ -961,7 +945,7 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
const int delta_cx,
const t_physical_tile_loc& from_loc,
t_bb search_range,
const t_bb& search_range,
t_physical_tile_loc& to_loc,
bool is_median,
int to_layer_num,
Expand Down Expand Up @@ -1006,24 +990,8 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
if (y_lower_iter == block_rows.end()) {
continue;
}

auto y_upper_iter = block_rows.upper_bound(search_range.ymax);

if (y_lower_iter->first > search_range.ymin) {
//No valid blocks at this x location which are within rlim_y
//
if (type->index != 1)
continue;
else {
//Fall back to allow the whole y range
y_lower_iter = block_rows.begin();
y_upper_iter = block_rows.end();

search_range.ymin = y_lower_iter->first;
search_range.ymax = (y_upper_iter - 1)->first;
}
}

int y_range = std::distance(y_lower_iter, y_upper_iter);
VTR_ASSERT(y_range >= 0);

Expand Down Expand Up @@ -1202,6 +1170,37 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
return true;
}

bool adjust_search_range(t_logical_block_type_ptr block_type,
ClusterBlockId block_id,
t_bb& search_range,
int& delta_cx,
int to_layer_num) {

auto block_constrained = is_cluster_constrained(block_id);

if (block_constrained) {
bool intersect = intersect_range_limit_with_floorplan_constraints(block_id,
search_range,
delta_cx,
to_layer_num);
if (!intersect) {
return false;
}
}

if (is_io_type(block_type) && !block_constrained) {
/* We empirically found that for the IO blocks,
* Given their sparsity, we expand the y-axis search range
* to include all blocks in the column
*/
const t_compressed_block_grid& compressed_block_grid = g_vpr_ctx.placement().compressed_block_grids[block_type->index];
search_range.ymin = 0;
search_range.ymax = compressed_block_grid.get_num_rows(to_layer_num) - 1;
}

return true;
}

std::string e_move_result_to_string(e_move_result move_outcome) {
switch (move_outcome) {
case e_move_result::REJECTED:
Expand Down
24 changes: 23 additions & 1 deletion vpr/src/place/move_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,12 @@ int find_empty_compatible_subtile(t_logical_block_type_ptr type,
* is_median: true if this is called from find_to_loc_median
* to_layer_num: the layer number of the new location (set by the caller)
* search_for_empty: indicates that the returned location must be empty
* fixed_search_range: indicates that the search range is fixed and should not be adjusted
*/
bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
int delta_cx,
const t_physical_tile_loc& from_loc,
t_bb search_range,
const t_bb& search_range,
t_physical_tile_loc& to_loc,
bool is_median,
int to_layer_num,
Expand Down Expand Up @@ -420,6 +421,27 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
int& delta_cx,
int layer_num);

/**
* @brief Adjust the search range based on the block type and constraints
*
* If the block is an IO block, we expand the search range to include all blocks in the column
* We found empirically that this is a good strategy for IO blocks given they are located in
* the periphery for most FPGA architectures
*
* @param block_type The type of the block to move
* @param block_id The block ID of the moving block
* @param search_range The search range to adjust
* @param delta_cx The delta x of the search range
* @param to_layer_num The layer that the block is moving to
*
* @return true if the search range was adjusted, false otherwise
*/
bool adjust_search_range(t_logical_block_type_ptr block_type,
ClusterBlockId block_id,
t_bb& search_range,
int& delta_cx,
int to_layer_num);

std::string e_move_result_to_string(e_move_result move_outcome);

/**
Expand Down
Loading
Loading