Skip to content

Floorplan constraints tuning #1741

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 9 commits into from
Jun 1, 2021
12 changes: 5 additions & 7 deletions vpr/src/base/partition_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ bool PartitionRegion::is_loc_in_part_reg(t_pl_loc loc) {
return is_in_pr;
}

PartitionRegion intersection(PartitionRegion& pr1, PartitionRegion& pr2) {
PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
/**for N regions in part_region and M in the calling object you can get anywhere from
* 0 to M*N regions in the resulting vector. Only intersection regions with non-zero area rectangles and
* equivalent subtiles are put in the resulting vector
* Rectangles are not merged even if it would be possible
*/
PartitionRegion pr;
Region intersect_region;
bool regions_intersect;
for (unsigned int i = 0; i < pr1.partition_region.size(); i++) {
for (unsigned int j = 0; j < pr2.partition_region.size(); j++) {
regions_intersect = do_regions_intersect(pr1.partition_region[i], pr2.partition_region[j]);
if (regions_intersect) {
intersect_region = intersection(pr1.partition_region[i], pr2.partition_region[j]);
for (unsigned int i = 0; i < cluster_pr.partition_region.size(); i++) {
for (unsigned int j = 0; j < new_pr.partition_region.size(); j++) {
intersect_region = intersection(cluster_pr.partition_region[i], new_pr.partition_region[j]);
if (!intersect_region.empty()) {
pr.partition_region.push_back(intersect_region);
}
}
Expand Down
2 changes: 1 addition & 1 deletion vpr/src/base/partition_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class PartitionRegion {
* @param pr1 One of the PartitionRegions to be intersected
* @param pr2 One of the PartitionRegions to be intersected
*/
friend PartitionRegion intersection(PartitionRegion& pr1, PartitionRegion& pr2);
friend PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionRegion& new_pr);

private:
std::vector<Region> partition_region; ///< union of rectangular regions that a partition can be placed in
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/base/region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Region::Region() {
region_bounds.set_ymax(-1);
}

vtr::Rect<int> Region::get_region_rect() {
vtr::Rect<int> Region::get_region_rect() const {
return region_bounds;
}

Expand All @@ -25,7 +25,7 @@ void Region::set_region_rect(int _xmin, int _ymin, int _xmax, int _ymax) {
region_bounds.set_ymax(_ymax);
}

int Region::get_sub_tile() {
int Region::get_sub_tile() const {
return sub_tile;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ bool do_regions_intersect(Region r1, Region r2) {
return intersect;
}

Region intersection(Region r1, Region r2) {
Region intersection(const Region& r1, const Region& r2) {
Region intersect;

/**
Expand Down
6 changes: 3 additions & 3 deletions vpr/src/base/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Region {
/**
* @brief Accessor for the region's rectangle
*/
vtr::Rect<int> get_region_rect();
vtr::Rect<int> get_region_rect() const;

/**
* @brief Mutator for the region's rectangle
Expand All @@ -33,7 +33,7 @@ class Region {
/**
* @brief Accessor for the region's subtile
*/
int get_sub_tile();
int get_sub_tile() const;

/**
* @brief Mutator for the region's subtile
Expand Down Expand Up @@ -84,7 +84,7 @@ bool do_regions_intersect(Region r1, Region r2);
* @param r2 One of the regions to intersect
*
*/
Region intersection(Region r1, Region r2);
Region intersection(const Region& r1, const Region& r2);

///@brief Used to print data from a Region
void print_region(FILE* fp, Region region);
Expand Down
7 changes: 2 additions & 5 deletions vpr/src/pack/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,13 +1726,12 @@ static enum e_block_pack_status atom_cluster_floorplanning_check(const AtomBlock
PartitionRegion& temp_cluster_pr,
bool& cluster_pr_needs_update) {
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
VprConstraints ctx_constraints = floorplanning_ctx.constraints;

/*check if the atom can go in the cluster by checking if the atom and cluster have intersecting PartitionRegions*/

//get partition that atom belongs to
PartitionId partid;
partid = ctx_constraints.get_atom_partition(blk_id);
partid = floorplanning_ctx.constraints.get_atom_partition(blk_id);

PartitionRegion atom_pr;
PartitionRegion cluster_pr;
Expand All @@ -1748,7 +1747,7 @@ static enum e_block_pack_status atom_cluster_floorplanning_check(const AtomBlock
return BLK_PASSED;
} else {
//get pr of that partition
atom_pr = ctx_constraints.get_partition_pr(partid);
atom_pr = floorplanning_ctx.constraints.get_partition_pr(partid);

//intersect it with the pr of the current cluster
cluster_pr = floorplanning_ctx.cluster_constraints[clb_index];
Expand Down Expand Up @@ -2229,8 +2228,6 @@ static void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats
auto& device_ctx = g_vpr_ctx.mutable_device();
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();

VprConstraints ctx_constraints = floorplanning_ctx.constraints;

/*Cluster's PartitionRegion is empty initially, meaning it has no floorplanning constraints*/
PartitionRegion empty_pr;
floorplanning_ctx.cluster_constraints.push_back(empty_pr);
Expand Down
7 changes: 7 additions & 0 deletions vpr/src/place/place_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include "globals.h"
#include "place_constraints.h"

/// @brief sentinel value for indicating that a subtile has not been specified
constexpr int NO_SUBTILE = -1;

/*checks that each block's location is compatible with its floorplanning constraints if it has any*/
int check_placement_floorplanning() {
int error = 0;
Expand Down Expand Up @@ -114,6 +117,10 @@ PartitionRegion constrained_macro_locs(const t_pl_macro& pl_macro) {
}

/*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
* propagation that was done during initial placement.
*/
bool cluster_floorplanning_legal(ClusterBlockId blk_id, const t_pl_loc& loc) {
auto& floorplanning_ctx = g_vpr_ctx.floorplanning();

Expand Down