-
Notifications
You must be signed in to change notification settings - Fork 408
[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
base: master
Are you sure you want to change the base?
Changes from 24 commits
0c355d8
42d06e7
b80abb5
0f038dc
271640b
a2ae770
01b55e8
df7a0c4
75e9474
2e4dc59
34c7571
c94c8b8
512eb7c
1da6e6d
a1d67f7
9c4057a
a27a74f
58a3522
43e33fa
3ea75f2
ac7a821
6871fc9
84790cf
9f8e498
e2b0c9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,52 @@ void set_placer_breakpoint_reached(bool flag) { | |
f_placer_breakpoint_reached = flag; | ||
} | ||
|
||
/** | ||
* @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 | ||
*/ | ||
static 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); | ||
amin1377 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could make this code work well for area-IO (e.g. stratix 10 where IOs are in columns) and for other sparse blocks by just checking if the number of blocks in the compressed columns is less than some threshold. I suspect you don't actually need to check if it is an IO block -- IOs are just an example of this kind of pattern. (I still like the utility to check if a logical block type is an IO though). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually tried that a while ago by not specifying the block type and simply expanding the search range if the number of blocks in the chosen column was less than 3. However, after making that change, in the example I mentioned earlier, we encountered the same issue where the IO blocks became scattered between the top and bottom edges. |
||
search_range.ymin = 0; | ||
search_range.ymax = compressed_block_grid.get_num_rows(to_layer_num) - 1; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
e_create_move create_move(t_pl_blocks_to_be_moved& blocks_affected, | ||
ClusterBlockId b_from, | ||
t_pl_loc to, | ||
|
@@ -669,18 +715,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, | ||
|
@@ -761,19 +802,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], | ||
|
@@ -850,20 +885,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], | ||
|
@@ -961,7 +991,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, | ||
|
@@ -1006,24 +1036,10 @@ 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; | ||
} | ||
continue; | ||
} | ||
|
||
int y_range = std::distance(y_lower_iter, y_upper_iter); | ||
VTR_ASSERT(y_range >= 0); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should explain a bit about why and how you adjust the search range.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the following: