Skip to content

Add constraints propagation to update the PartitionRegions of blocks … #1751

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

Merged
merged 13 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
21 changes: 13 additions & 8 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@ static int check_macro_can_be_placed(t_pl_macro pl_macro, int itype, t_pl_loc he
// Every macro can be placed until proven otherwise
int macro_can_be_placed = true;

//Check whether macro contains blocks with floorplan constraints
bool macro_constrained = is_macro_constrained(pl_macro);
PartitionRegion macro_pr;

if (macro_constrained) {
macro_pr = constrained_macro_locs(pl_macro);
}

// Check whether all the members can be placed
for (size_t imember = 0; imember < pl_macro.members.size(); imember++) {
t_pl_loc member_pos = head_pos + pl_macro.members[imember].offset;

//if the macro is constrained, check if the member position is within the PartitionRegion for the macro
if (macro_constrained) {
bool member_loc_good = macro_pr.is_loc_in_part_reg(member_pos);
/*
* If the macro is constrained, check that the head member is in a legal position from
* a floorplanning perspective. It is enough to do this check for the head member alone,
* because constraints propagation was performed to calculate smallest floorplan region for the head
* macro, based on the constraints on all of the blocks in the macro. So, if the head macro is in a
* legal floorplan location, all other blocks in the macro will be as well.
*/
if (macro_constrained && imember == 0) {
bool member_loc_good = cluster_floorplanning_legal(pl_macro.members[imember].blk_index, member_pos);
if (!member_loc_good) {
macro_can_be_placed = false;
break;
Expand Down Expand Up @@ -417,6 +419,9 @@ void initial_placement(enum e_pad_loc_type pad_loc_type, const char* constraints
vtr::vector<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
std::vector<ClusterBlockId> sorted_blocks = sort_blocks(block_scores);

//Perform constraints_propagation
constraints_propagation();

// Loading legal placement locations
zero_initialize_grid_blocks();
alloc_and_load_legal_placement_locations(legal_pos);
Expand Down
23 changes: 21 additions & 2 deletions vpr/src/place/place_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ bool is_macro_constrained(const t_pl_macro& pl_macro) {
}

/*Returns PartitionRegion of where the head of the macro could go*/
PartitionRegion constrained_macro_locs(const t_pl_macro& pl_macro) {
PartitionRegion update_macro_pr(const t_pl_macro& pl_macro) {
PartitionRegion macro_pr;
bool is_member_constrained = false;
int num_constrained_members = 0;
Expand Down Expand Up @@ -90,7 +90,7 @@ PartitionRegion constrained_macro_locs(const t_pl_macro& pl_macro) {

modified_reg.set_region_rect(modified_min_pl_loc.x, modified_min_pl_loc.y, modified_max_pl_loc.x, modified_max_pl_loc.y);
//check that subtile is not an invalid value before changing, otherwise it just stays -1
if (block_regions[i].get_sub_tile() != -1) {
if (block_regions[i].get_sub_tile() != NO_SUBTILE) {
modified_reg.set_sub_tile(modified_min_pl_loc.sub_tile);
}

Expand All @@ -113,6 +113,25 @@ PartitionRegion constrained_macro_locs(const t_pl_macro& pl_macro) {
return macro_pr;
}

void constraints_propagation() {
auto& place_ctx = g_vpr_ctx.placement();
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();

for (auto pl_macro : place_ctx.pl_macros) {
if (is_macro_constrained(pl_macro)) {
/*
* Update the PartitionRegion for the head of the macro
* based on the constraints of all blocks contained in the macro
*/
PartitionRegion macro_head_pr = update_macro_pr(pl_macro);

//Get block id of head macro member and update its PartitionRegion
ClusterBlockId blk_id = pl_macro.members[0].blk_index;
floorplanning_ctx.cluster_constraints[blk_id] = macro_head_pr;
}
}
}

/*returns true if location is compatible with floorplanning constraints, false if not*/
/*
* Even if the block passed in is from a macro, it will work because of the constraints
Expand Down
14 changes: 12 additions & 2 deletions vpr/src/place/place_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ bool cluster_floorplanning_legal(ClusterBlockId blk_id, const t_pl_loc& loc);
bool is_macro_constrained(const t_pl_macro& pl_macro);

/*
* Returns region of valid locations for the head of the macro based on floorplan constraints
* Returns PartitionRegion for the head of the macro based on the floorplan constraints
* of all blocks in the macro.
*/
PartitionRegion constrained_macro_locs(const t_pl_macro& pl_macro);
PartitionRegion update_macro_pr(const t_pl_macro& pl_macro);

/*
* Updates the floorplan constraints information for all constrained macros.
* The head member of each constrained macro is assigned a new PartitionRegion
* that is calculated based on the constraints of all the blocks in the macro.
* This is done at the start of initial placement to ease floorplan legality checking
* while placing macros during initial placement.
*/
void constraints_propagation();

inline bool floorplan_legal(const t_pl_blocks_to_be_moved& blocks_affected) {
bool floorplan_legal;
Expand Down