@@ -36,18 +36,43 @@ bool PartitionRegion::is_loc_in_part_reg(const t_pl_loc& loc) const {
36
36
return is_in_pr;
37
37
}
38
38
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
+
39
55
PartitionRegion intersection (const PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
40
56
/* *for N regions in part_region and M in the calling object you can get anywhere from
41
57
* 0 to M*N regions in the resulting vector. Only intersection regions with non-zero area rectangles and
42
58
* equivalent subtiles are put in the resulting vector
43
59
* Rectangles are not merged even if it would be possible
44
60
*/
45
61
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
+
46
71
auto & pr_regions = pr.get_mutable_regions ();
47
- Region intersect_region;
72
+
48
73
for (const auto & cluster_region : cluster_pr.get_regions ()) {
49
74
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);
51
76
if (!intersect_region.empty ()) {
52
77
pr_regions.push_back (intersect_region);
53
78
}
@@ -60,14 +85,23 @@ PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionR
60
85
void update_cluster_part_reg (PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
61
86
std::vector<Region> int_regions;
62
87
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
+ }
68
101
}
69
102
}
70
103
}
104
+
71
105
cluster_pr.set_partition_region (int_regions);
72
106
}
73
107
0 commit comments