Skip to content

Commit 71f85c5

Browse files
add exclusivity index to PartitionRegion
1 parent 3777e5f commit 71f85c5

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

vpr/src/base/partition_region.cpp

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,43 @@ bool PartitionRegion::is_loc_in_part_reg(const t_pl_loc& loc) const {
3636
return is_in_pr;
3737
}
3838

39+
int PartitionRegion::get_exclusivity_index() const {
40+
return exclusivity_index;
41+
}
42+
43+
void PartitionRegion::set_exclusivity_index(int index) {
44+
/* negative exclusivity index means this PartitionRegion is compatible
45+
* with other PartitionsRegions as long as the intersection of their
46+
* regions is not empty.
47+
*/
48+
if (index < 0) {
49+
index = -1;
50+
}
51+
52+
exclusivity_index = index;
53+
}
54+
3955
PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
4056
/**for N regions in part_region and M in the calling object you can get anywhere from
4157
* 0 to M*N regions in the resulting vector. Only intersection regions with non-zero area rectangles and
4258
* equivalent subtiles are put in the resulting vector
4359
* Rectangles are not merged even if it would be possible
4460
*/
4561
PartitionRegion pr;
62+
63+
const int cluster_exclusivity = cluster_pr.get_exclusivity_index();
64+
const int new_exclusivity = new_pr.get_exclusivity_index();
65+
66+
// PartitionRegion are not compatible even if their regions overlap
67+
if (cluster_exclusivity != new_exclusivity) {
68+
return pr;
69+
}
70+
4671
auto& pr_regions = pr.get_mutable_regions();
47-
Region intersect_region;
72+
4873
for (const auto& cluster_region : cluster_pr.get_regions()) {
4974
for (const auto& new_region : new_pr.get_regions()) {
50-
intersect_region = intersection(cluster_region, new_region);
75+
Region intersect_region = intersection(cluster_region, new_region);
5176
if (!intersect_region.empty()) {
5277
pr_regions.push_back(intersect_region);
5378
}
@@ -60,14 +85,23 @@ PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionR
6085
void update_cluster_part_reg(PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
6186
std::vector<Region> int_regions;
6287

63-
for (const auto& cluster_region : cluster_pr.get_regions()) {
64-
for (const auto& new_region : new_pr.get_regions()) {
65-
Region intersect_region = intersection(cluster_region, new_region);
66-
if (!intersect_region.empty()) {
67-
int_regions.push_back(intersect_region);
88+
const int cluster_exclusivity = cluster_pr.get_exclusivity_index();
89+
const int new_exclusivity = new_pr.get_exclusivity_index();
90+
91+
// check whether PartitionRegions are compatible in the first place
92+
if (cluster_exclusivity == new_exclusivity) {
93+
94+
// now that we know PartitionRegions are compatible, look for overlapping regions
95+
for (const auto& cluster_region : cluster_pr.get_regions()) {
96+
for (const auto& new_region : new_pr.get_regions()) {
97+
Region intersect_region = intersection(cluster_region, new_region);
98+
if (!intersect_region.empty()) {
99+
int_regions.push_back(intersect_region);
100+
}
68101
}
69102
}
70103
}
104+
71105
cluster_pr.set_partition_region(int_regions);
72106
}
73107

vpr/src/base/partition_region.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,28 @@ class PartitionRegion {
5050
*/
5151
bool is_loc_in_part_reg(const t_pl_loc& loc) const;
5252

53+
int get_exclusivity_index() const;
54+
55+
void set_exclusivity_index(int index);
56+
5357
private:
5458
std::vector<Region> regions; ///< union of rectangular regions that a partition can be placed in
59+
int exclusivity_index = -1; ///< PartitionRegions with different exclusivity_index values are not compatible
5560
};
5661

5762
///@brief used to print data from a PartitionRegion
5863
void print_partition_region(FILE* fp, const PartitionRegion& pr);
5964

6065
/**
61-
* @brief Global friend function that returns the intersection of two PartitionRegions
66+
* @brief Global function that returns the intersection of two PartitionRegions
6267
*
6368
* @param cluster_pr One of the PartitionRegions to be intersected
6469
* @param new_pr One of the PartitionRegions to be intersected
6570
*/
6671
PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionRegion& new_pr);
6772

6873
/**
69-
* @brief Global friend function that updates the PartitionRegion of a cluster with the intersection
74+
* @brief Global function that updates the PartitionRegion of a cluster with the intersection
7075
* of the cluster PartitionRegion and a new PartitionRegion
7176
*
7277
* @param cluster_pr The cluster PartitionRegion that is to be updated

0 commit comments

Comments
 (0)