Skip to content

Commit 1c608ca

Browse files
committed
Applied offsets directly to region rectangles when updating macro PartitionRegions to reduce length of functions. Also improved error messages for constraints propagation
1 parent c8b4a59 commit 1c608ca

File tree

3 files changed

+27
-28
lines changed

3 files changed

+27
-28
lines changed

vpr/src/place/place_constraints.cpp

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,11 @@ PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro, const Partition
8080

8181
vtr::Rect<int> reg_rect = block_regions[i].get_region_rect();
8282

83-
t_pl_loc min_pl_loc(reg_rect.xmin(), reg_rect.ymin(), block_regions[i].get_sub_tile());
83+
modified_reg.set_region_rect(reg_rect.xmin() - offset.x, reg_rect.ymin() - offset.y, reg_rect.xmax() - offset.x, reg_rect.ymax() - offset.y);
8484

85-
t_pl_loc modified_min_pl_loc = min_pl_loc - offset;
86-
87-
t_pl_loc max_pl_loc(reg_rect.xmax(), reg_rect.ymax(), block_regions[i].get_sub_tile());
88-
89-
t_pl_loc modified_max_pl_loc = max_pl_loc - offset;
90-
91-
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);
9285
//check that subtile is not an invalid value before changing, otherwise it just stays -1
9386
if (block_regions[i].get_sub_tile() != NO_SUBTILE) {
94-
modified_reg.set_sub_tile(modified_min_pl_loc.sub_tile);
87+
modified_reg.set_sub_tile(block_regions[i].get_sub_tile() - offset.sub_tile);
9588
}
9689

9790
modified_pr.add_to_part_region(modified_reg);
@@ -110,13 +103,13 @@ PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro, const Partition
110103

111104
//if the intersection is empty, no way to place macro members together, give an error
112105
if (macro_head_pr.empty()) {
113-
VPR_ERROR(VPR_ERROR_PLACE, " \n Feasible floorplanning constraints could not be calculated for the placement macro.\n");
106+
print_macro_constraint_error(pl_macro);
114107
}
115108

116109
return macro_head_pr;
117110
}
118111

119-
PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offset& offset, const PartitionRegion& grid_pr) {
112+
PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offset& offset, const PartitionRegion& grid_pr, const t_pl_macro& pl_macro) {
120113
std::vector<Region> block_regions = head_pr.get_partition_region();
121114
PartitionRegion macro_pr;
122115

@@ -125,34 +118,38 @@ PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offs
125118

126119
vtr::Rect<int> reg_rect = block_regions[i].get_region_rect();
127120

128-
t_pl_loc min_pl_loc(reg_rect.xmin(), reg_rect.ymin(), block_regions[i].get_sub_tile());
129-
130-
t_pl_loc macro_min_pl_loc = min_pl_loc + offset;
131-
132-
t_pl_loc max_pl_loc(reg_rect.xmax(), reg_rect.ymax(), block_regions[i].get_sub_tile());
121+
modified_reg.set_region_rect(reg_rect.xmin() + offset.x, reg_rect.ymin() + offset.y, reg_rect.xmax() + offset.x, reg_rect.ymax() + offset.y);
133122

134-
t_pl_loc macro_max_pl_loc = max_pl_loc + offset;
135-
136-
modified_reg.set_region_rect(macro_min_pl_loc.x, macro_min_pl_loc.y, macro_max_pl_loc.x, macro_max_pl_loc.y);
137123
//check that subtile is not an invalid value before changing, otherwise it just stays -1
138124
if (block_regions[i].get_sub_tile() != NO_SUBTILE) {
139-
modified_reg.set_sub_tile(macro_min_pl_loc.sub_tile);
125+
modified_reg.set_sub_tile(block_regions[i].get_sub_tile() + offset.sub_tile);
140126
}
141127

142128
macro_pr.add_to_part_region(modified_reg);
143129
}
144130

145-
//intersect to ensure the head pr does not go outside of grid dimensions
131+
//intersect to ensure the macro pr does not go outside of grid dimensions
146132
macro_pr = intersection(macro_pr, grid_pr);
147133

148134
//if the intersection is empty, no way to place macro members together, give an error
149135
if (macro_pr.empty()) {
150-
VPR_ERROR(VPR_ERROR_PLACE, " \n Feasible floorplanning constraints could not be calculated for the placement macro.\n");
136+
print_macro_constraint_error(pl_macro);
151137
}
152138

153139
return macro_pr;
154140
}
155141

142+
void print_macro_constraint_error(const t_pl_macro& pl_macro) {
143+
VTR_LOG(
144+
"Feasible floorplanning constraints could not be calculated for the placement macro. \n"
145+
"The placement macro contains the following blocks: \n");
146+
for (unsigned int i = 0; i < pl_macro.members.size(); i++) {
147+
VTR_LOG("Block #%zu ", size_t(pl_macro.members[i].blk_index));
148+
}
149+
VTR_LOG("\n");
150+
VPR_ERROR(VPR_ERROR_PLACE, " \n Check that the above-mentioned placement macro blocks have compatible floorplan constraints.\n");
151+
}
152+
156153
void propagate_place_constraints() {
157154
auto& place_ctx = g_vpr_ctx.placement();
158155
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
@@ -170,7 +167,7 @@ void propagate_place_constraints() {
170167
for (auto pl_macro : place_ctx.pl_macros) {
171168
if (is_macro_constrained(pl_macro)) {
172169
/*
173-
* Update the PartitionRegion for the head of the macro
170+
* Get the PartitionRegion for the head of the macro
174171
* based on the constraints of all blocks contained in the macro
175172
*/
176173
PartitionRegion macro_head_pr = update_macro_head_pr(pl_macro, grid_pr);
@@ -180,11 +177,10 @@ void propagate_place_constraints() {
180177
ClusterBlockId iblk = pl_macro.members[imember].blk_index;
181178
auto offset = pl_macro.members[imember].offset;
182179

183-
//Update head PR
184-
if (imember == 0) {
180+
if (imember == 0) { //Update head PR
185181
floorplanning_ctx.cluster_constraints[iblk] = macro_head_pr;
186182
} else { //Update macro member PR
187-
PartitionRegion macro_pr = update_macro_member_pr(macro_head_pr, offset, grid_pr);
183+
PartitionRegion macro_pr = update_macro_member_pr(macro_head_pr, offset, grid_pr, pl_macro);
188184
floorplanning_ctx.cluster_constraints[iblk] = macro_pr;
189185
}
190186
}

vpr/src/place/place_constraints.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ PartitionRegion update_macro_head_pr(const t_pl_macro& pl_macro, const Partition
5050
* For each macro member, the updated constraint is essentially the head constraint
5151
* with the member's offset applied.
5252
*/
53-
PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offset& offset, const PartitionRegion& grid_pr);
53+
PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offset& offset, const PartitionRegion& grid_pr, const t_pl_macro& pl_macro);
5454

5555
/*
5656
* Updates the floorplan constraints information for all constrained macros.
@@ -61,6 +61,8 @@ PartitionRegion update_macro_member_pr(PartitionRegion& head_pr, const t_pl_offs
6161
*/
6262
void propagate_place_constraints();
6363

64+
void print_macro_constraint_error(const t_pl_macro& pl_macro);
65+
6466
inline bool floorplan_legal(const t_pl_blocks_to_be_moved& blocks_affected) {
6567
bool floorplan_legal;
6668

vpr/test/test_vpr_constraints.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ TEST_CASE("RegionLocked", "[vpr]") {
428428

429429
//Test calculation of macro constraints
430430
TEST_CASE("MacroConstraints", "[vpr]") {
431+
t_pl_macro pl_macro;
431432
PartitionRegion head_pr;
432433
t_pl_offset offset(2, 1, 0);
433434

@@ -441,7 +442,7 @@ TEST_CASE("MacroConstraints", "[vpr]") {
441442
PartitionRegion grid_pr;
442443
grid_pr.add_to_part_region(grid_reg);
443444

444-
PartitionRegion macro_pr = update_macro_member_pr(head_pr, offset, grid_pr);
445+
PartitionRegion macro_pr = update_macro_member_pr(head_pr, offset, grid_pr, pl_macro);
445446

446447
std::vector<Region> mac_regions = macro_pr.get_partition_region();
447448

0 commit comments

Comments
 (0)