Skip to content

Commit e97bfff

Browse files
update place_constraints.cpp to support layer range
1 parent 25e5145 commit e97bfff

File tree

8 files changed

+167
-138
lines changed

8 files changed

+167
-138
lines changed

libs/libvtrutil/src/vtr_geometry.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,18 @@ class Point {
9292
///@brief Swap x and y values
9393
void swap();
9494

95+
/// @brief += operator
96+
Point<T>& operator+= (const Point<T>& rhs);
97+
98+
/// @brief += operator
99+
Point<T>& operator-= (const Point<T>& rhs);
100+
95101
private:
96102
T x_;
97103
T y_;
98104
};
99105

106+
100107
/**
101108
* @brief A 2D rectangle
102109
*
@@ -193,6 +200,11 @@ class Rect {
193200
///@brief set ymax to a point
194201
void set_ymax(T ymax_val);
195202

203+
/// @brief += operator
204+
Rect<T>& operator+= (const Point<T>& rhs);
205+
206+
Rect<T>& operator-= (const Point<T>& rhs);
207+
196208
///@brief Equivalent to `*this = bounding_box(*this, other)`
197209
Rect<T>& expand_bounding_box(const Rect<T>& other);
198210

libs/libvtrutil/src/vtr_geometry.tpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ void Point<T>::swap() {
5858
std::swap(x_, y_);
5959
}
6060

61+
template<class T>
62+
Point<T>& Point<T>::operator+=(const Point<T>& rhs) {
63+
x_ += rhs.x_;
64+
y_ += rhs.y_;
65+
return *this;
66+
}
67+
68+
template<class T>
69+
Point<T>& Point<T>::operator-=(const Point<T>& rhs) {
70+
x_ -= rhs.x_;
71+
y_ -= rhs.y_;
72+
return *this;
73+
}
74+
6175
/*
6276
* Rect
6377
*/
@@ -229,6 +243,20 @@ void Rect<T>::set_ymax(T ymax_val) {
229243
top_right_.set_y(ymax_val);
230244
}
231245

246+
template<class T>
247+
Rect<T>& Rect<T>::operator+=(const Point<T>& rhs) {
248+
bottom_left_ += rhs;
249+
top_right_ += rhs;
250+
return *this;
251+
}
252+
253+
template<class T>
254+
Rect<T>& Rect<T>::operator-=(const Point<T>& rhs) {
255+
bottom_left_ -= rhs;
256+
top_right_ -= rhs;
257+
return *this;
258+
}
259+
232260
template<class T>
233261
Rect<T>& Rect<T>::expand_bounding_box(const Rect<T>& other) {
234262
*this = bounding_box(*this, other);

vpr/src/base/region.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ Region intersection(const Region& r1, const Region& r2) {
120120
auto [r2_layer_begin, r2_layer_end] = r2.get_region_bounds().get_layer_range();
121121

122122
auto [intersect_layer_begin, intersect_layer_end] = std::make_pair(std::max(r1_layer_begin, r2_layer_begin),
123-
std::min(r1_layer_end, r2_layer_begin));
123+
std::min(r1_layer_end, r2_layer_end));
124124

125125
if (intersect_layer_begin > intersect_layer_end || intersect_layer_begin < 0 || intersect_layer_end < 0) {
126126
return {};

vpr/src/base/vpr_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ struct FloorplanningContext : public Context {
529529
* - The bottom left corner is rounded up to the nearest compressed location.
530530
* - The top right corner is rounded down to the nearest compressed location.
531531
*/
532-
vtr::vector<ClusterBlockId, PartitionRegion> compressed_cluster_constraints;
532+
std::vector<vtr::vector<ClusterBlockId, PartitionRegion>> compressed_cluster_constraints;
533533

534534
std::vector<Region> overfull_regions;
535535
};

vpr/src/place/initial_placement.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,6 @@ static bool place_macro(int macros_max_num_tries,
837837
bool macro_placed = false;
838838
auto& cluster_ctx = g_vpr_ctx.clustering();
839839
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
840-
auto& device_ctx = g_vpr_ctx.device();
841840

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

vpr/src/place/move_utils.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
12641264
const auto& floorplanning_ctx = g_vpr_ctx.floorplanning();
12651265

12661266
// get the block floorplanning constraints specified in the compressed grid
1267-
const PartitionRegion& compressed_pr = floorplanning_ctx.compressed_cluster_constraints[b_from];
1267+
const PartitionRegion& compressed_pr = floorplanning_ctx.compressed_cluster_constraints[layer_num][b_from];
12681268
const std::vector<Region>& compressed_regions = compressed_pr.get_regions();
12691269
/*
12701270
* If region size is greater than 1, the block is constrained to more than one rectangular region.
@@ -1275,9 +1275,9 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
12751275
*/
12761276
if (compressed_regions.size() == 1) {
12771277
Region range_reg;
1278-
range_reg.set_region_rect({search_range.xmin, search_range.ymin,
1279-
search_range.xmax, search_range.ymax,
1280-
layer_num});
1278+
range_reg.set_region_bounds({search_range.xmin, search_range.ymin,
1279+
search_range.xmax, search_range.ymax,
1280+
layer_num});
12811281

12821282
Region compressed_intersect_reg = intersection(compressed_regions[0], range_reg);
12831283

@@ -1286,15 +1286,15 @@ bool intersect_range_limit_with_floorplan_constraints(ClusterBlockId b_from,
12861286
"\tCouldn't find an intersection between floorplan constraints and search region\n");
12871287
return false;
12881288
} else {
1289-
const auto intersect_coord = compressed_intersect_reg.get_region_rect();
1290-
VTR_ASSERT(intersect_coord.layer_num == layer_num);
1291-
1292-
delta_cx = intersect_coord.xmax - intersect_coord.xmin;
1293-
search_range.xmin = intersect_coord.xmin;
1294-
search_range.ymin = intersect_coord.ymin;
1295-
search_range.xmax = intersect_coord.xmax;
1296-
search_range.ymax = intersect_coord.ymax;
1297-
search_range.layer_max = search_range.layer_min = layer_num;
1289+
const vtr::Rect<int>& intersect_rect = compressed_intersect_reg.get_region_bounds().get_rect();
1290+
const auto [layer_low, layer_high] = compressed_intersect_reg.get_region_bounds().get_layer_range();
1291+
VTR_ASSERT(layer_low == layer_num && layer_high == layer_num);
1292+
1293+
delta_cx = intersect_rect.xmax() - intersect_rect.xmin();
1294+
std::tie(search_range.xmin, search_range.ymin,
1295+
search_range.xmax, search_range.ymax) = intersect_rect.coordinates();
1296+
search_range.layer_min = layer_low;
1297+
search_range.layer_max = layer_high;
12981298
}
12991299
}
13001300

0 commit comments

Comments
 (0)