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 33 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
8 changes: 7 additions & 1 deletion vpr/src/place/initial_noc_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ static void place_constrained_noc_router(ClusterBlockId router_blk_id,

bool macro_placed = false;
for (int i_try = 0; i_try < MAX_NUM_TRIES_TO_PLACE_MACROS_RANDOMLY && !macro_placed; i_try++) {
macro_placed = try_place_macro_randomly(pl_macro, pr, block_type, e_pad_loc_type::FREE, blk_loc_registry, rng);
macro_placed = try_place_macro_randomly(pl_macro,
pr,
/*block_constrained*/ true,
block_type,
e_pad_loc_type::FREE,
blk_loc_registry,
rng);
}

if (!macro_placed) {
Expand Down
21 changes: 14 additions & 7 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static std::vector<ClusterBlockId> find_centroid_loc(const t_pl_macro& pl_macro,
static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
t_logical_block_type_ptr block_type,
bool search_for_empty,
bool block_constrained,
int r_lim,
const BlkLocRegistry& blk_loc_registry,
vtr::RngContainer& rng);
Expand All @@ -227,6 +228,7 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
*/
static bool try_centroid_placement(const t_pl_macro& pl_macro,
const PartitionRegion& pr,
bool block_constrained,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
Expand Down Expand Up @@ -403,6 +405,7 @@ bool find_subtile_in_location(t_pl_loc& centroid,
static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
t_logical_block_type_ptr block_type,
bool search_for_empty,
bool block_constrained,
int rlim,
const BlkLocRegistry& blk_loc_registry,
vtr::RngContainer& rng) {
Expand Down Expand Up @@ -440,6 +443,7 @@ static bool find_centroid_neighbor(t_pl_loc& centroid_loc,
/*is_median=*/false,
centroid_loc_layer_num,
search_for_empty,
block_constrained,
blk_loc_registry,
rng);

Expand Down Expand Up @@ -834,6 +838,7 @@ static inline t_pl_loc find_nearest_compatible_loc(const t_flat_pl_loc& src_flat

static bool try_centroid_placement(const t_pl_macro& pl_macro,
const PartitionRegion& pr,
bool block_constrained,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
vtr::vector<ClusterBlockId, t_block_score>& block_scores,
Expand Down Expand Up @@ -889,7 +894,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(centroid_loc, block_type, false, block_constrained, rlim, blk_loc_registry, rng);
if (!neighbor_legal_loc) { //no neighbor candidate found
return false;
}
Expand Down Expand Up @@ -1024,6 +1029,7 @@ static inline void fix_IO_block_types(const t_pl_macro& pl_macro,

bool try_place_macro_randomly(const t_pl_macro& pl_macro,
const PartitionRegion& pr,
bool block_constrained,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
BlkLocRegistry& blk_loc_registry,
Expand Down Expand Up @@ -1075,6 +1081,7 @@ bool try_place_macro_randomly(const t_pl_macro& pl_macro,
/*is_median=*/false,
selected_layer,
/*search_for_empty=*/false,
block_constrained,
blk_loc_registry,
rng);

Expand Down Expand Up @@ -1282,13 +1289,13 @@ static bool place_macro(int macros_max_num_tries,

// Assume that all the blocks in the macro are of the same type
auto block_type = cluster_ctx.clb_nlist.block_type(blk_id);

const PartitionRegion& pr = (is_cluster_constrained(blk_id)) ? floorplanning_ctx.cluster_constraints[blk_id]
: get_device_partition_region();
auto block_constrained = is_cluster_constrained(blk_id);
const PartitionRegion& pr = block_constrained ? floorplanning_ctx.cluster_constraints[blk_id]
: get_device_partition_region();

//Enough to check head member of macro to see if its constrained because
//constraints propagation was done earlier in initial placement.
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug && is_cluster_constrained(blk_id),
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug && block_constrained,
"\t\t\tMacro's head is constrained\n");

//If blk_types_empty_locs_in_grid is not NULL, means that initial placement has been failed in first iteration for this block type
Expand All @@ -1300,13 +1307,13 @@ 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(pl_macro, pr, block_constrained, 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
for (int itry = 0; itry < macros_max_num_tries && !macro_placed; itry++) {
VTR_LOGV_DEBUG(g_vpr_ctx.placement().f_placer_debug, "\t\t\tTry random place iter: %d\n", itry);
macro_placed = try_place_macro_randomly(pl_macro, pr, block_type, pad_loc_type, blk_loc_registry, rng);
macro_placed = try_place_macro_randomly(pl_macro, pr, block_constrained, block_type, pad_loc_type, blk_loc_registry, rng);
} // Finished all tries

if (!macro_placed) {
Expand Down
1 change: 1 addition & 0 deletions vpr/src/place/initial_placement.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ struct t_grid_empty_locs_block_type {
*/
bool try_place_macro_randomly(const t_pl_macro& pl_macro,
const PartitionRegion& pr,
bool block_constrained,
t_logical_block_type_ptr block_type,
e_pad_loc_type pad_loc_type,
BlkLocRegistry& blk_loc_registry,
Expand Down
52 changes: 28 additions & 24 deletions vpr/src/place/move_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
//Note: The flag is only effective if compiled with VTR_ENABLE_DEBUG_LOGGING
bool f_placer_breakpoint_reached = false;

constexpr int MIN_NUMBER_OF_BLOCK_PER_COLUMN = 3;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a comment. Better name would be MIN_BLK_PER_COLUMN_EXPAND (or something like that). Current name makes it sound like we can't have fewer blocks than that in a column.
I also think this should be pushed down to the routine that uses it, if it is only used in one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the variable to the routine and added the following comment:

// If the number of blocks in a column is less than this number, we 
// will expand the search range to the whole column


//Accessor for f_placer_breakpoint_reached
bool placer_breakpoint_reached() {
return f_placer_breakpoint_reached;
Expand Down Expand Up @@ -669,10 +671,9 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
rlim);
int delta_cx = search_range.xmax - search_range.xmin;

t_physical_tile_loc to_compressed_loc;
bool legal = false;
auto block_constrained = is_cluster_constrained(b_from);

if (is_cluster_constrained(b_from)) {
if (block_constrained) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
Expand All @@ -681,6 +682,9 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
return false;
}
}

t_physical_tile_loc to_compressed_loc;
bool legal = false;
//TODO: For now, we only move the blocks on the same tile
legal = find_compatible_compressed_loc_in_range(type,
delta_cx,
Expand All @@ -690,6 +694,7 @@ bool find_to_loc_uniform(t_logical_block_type_ptr type,
/*is_median=*/false,
to_layer_num,
/*search_for_empty=*/false,
block_constrained,
blk_loc_registry,
rng);

Expand Down Expand Up @@ -761,10 +766,9 @@ 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;
auto block_constrained = is_cluster_constrained(b_from);

if (is_cluster_constrained(b_from)) {
if (block_constrained) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
Expand All @@ -774,6 +778,8 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
}
}

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 All @@ -782,6 +788,7 @@ bool find_to_loc_median(t_logical_block_type_ptr blk_type,
/*is_median=*/true,
to_layer_num,
/*search_for_empty=*/false,
block_constrained,
blk_loc_registry,
rng);

Expand Down Expand Up @@ -850,10 +857,9 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
}
delta_cx = search_range.xmax - search_range.xmin;

t_physical_tile_loc to_compressed_loc;
bool legal = false;
auto block_constrained = is_cluster_constrained(b_from);

if (is_cluster_constrained(b_from)) {
if (block_constrained) {
bool intersect = intersect_range_limit_with_floorplan_constraints(b_from,
search_range,
delta_cx,
Expand All @@ -863,7 +869,10 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
}
}

//TODO: For now, we only move the blocks on the same tile
t_physical_tile_loc to_compressed_loc;
bool legal = false;

//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 All @@ -872,6 +881,7 @@ bool find_to_loc_centroid(t_logical_block_type_ptr blk_type,
/*is_median=*/false,
to_layer_num,
/*search_for_empty=*/false,
block_constrained,
blk_loc_registry,
rng);

Expand Down Expand Up @@ -966,6 +976,7 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
bool is_median,
int to_layer_num,
bool search_for_empty,
bool block_constrained,
const BlkLocRegistry& blk_loc_registry,
vtr::RngContainer& rng) {
//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
Expand Down Expand Up @@ -1006,22 +1017,15 @@ 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;
}
if (block_rows.size() < MIN_NUMBER_OF_BLOCK_PER_COLUMN && !block_constrained) {
//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);
Expand Down
2 changes: 2 additions & 0 deletions vpr/src/place/move_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ 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,
Expand All @@ -337,6 +338,7 @@ bool find_compatible_compressed_loc_in_range(t_logical_block_type_ptr type,
bool is_median,
int to_layer_num,
bool search_for_empty,
bool block_constrained,
const BlkLocRegistry& blk_loc_registry,
vtr::RngContainer& rng);

Expand Down
Loading
Loading