Skip to content

Commit 3a86fac

Browse files
committed
Added function to directly update a cluster's PartitionRegion that is passed in, rather than returning a new PartitionRegion. This function is a more efficient version of the PartitionRegion intersection function, and is now used during the atom floorplanning checks that happen during clustering
1 parent 47d0622 commit 3a86fac

File tree

4 files changed

+39
-7
lines changed

4 files changed

+39
-7
lines changed

vpr/src/base/partition_region.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ std::vector<Region> PartitionRegion::get_partition_region() {
99
return partition_region;
1010
}
1111

12+
void PartitionRegion::set_partition_region(std::vector<Region> pr) {
13+
partition_region = pr;
14+
}
15+
1216
bool PartitionRegion::empty() {
1317
return partition_region.size() == 0;
1418
}
@@ -46,6 +50,20 @@ PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionR
4650
return pr;
4751
}
4852

53+
void update_cluster_part_reg(PartitionRegion& cluster_pr, const PartitionRegion& new_pr) {
54+
Region intersect_region;
55+
std::vector<Region> int_regions;
56+
for (unsigned int i = 0; i < cluster_pr.partition_region.size(); i++) {
57+
for (unsigned int j = 0; j < new_pr.partition_region.size(); j++) {
58+
intersect_region = intersection(cluster_pr.partition_region[i], new_pr.partition_region[j]);
59+
if (!intersect_region.empty()) {
60+
int_regions.push_back(intersect_region);
61+
}
62+
}
63+
}
64+
cluster_pr.set_partition_region(int_regions);
65+
}
66+
4967
void print_partition_region(FILE* fp, PartitionRegion pr) {
5068
std::vector<Region> part_region = pr.get_partition_region();
5169

vpr/src/base/partition_region.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ class PartitionRegion {
2727
*/
2828
std::vector<Region> get_partition_region();
2929

30+
/**
31+
* @brief Set the union of regions
32+
*/
33+
void set_partition_region(std::vector<Region> pr);
34+
3035
/**
3136
* @brief Check if the PartitionRegion is empty (meaning there is no constraint on the object the PartitionRegion belongs to)
3237
*/
@@ -43,11 +48,20 @@ class PartitionRegion {
4348
/**
4449
* @brief Global friend function that returns the intersection of two PartitionRegions
4550
*
46-
* @param pr1 One of the PartitionRegions to be intersected
47-
* @param pr2 One of the PartitionRegions to be intersected
51+
* @param cluster_pr One of the PartitionRegions to be intersected
52+
* @param new_pr One of the PartitionRegions to be intersected
4853
*/
4954
friend PartitionRegion intersection(const PartitionRegion& cluster_pr, const PartitionRegion& new_pr);
5055

56+
/**
57+
* @brief Global friend function that updates the PartitionRegion of a cluster with the intersection
58+
* of the cluster PartitionRegion and a new PartitionRegion
59+
*
60+
* @param cluster_pr The cluster PartitionRegion that is to be updated
61+
* @param new_pr The new PartitionRegion that the cluster PartitionRegion will be intersected with
62+
*/
63+
friend void update_cluster_part_reg(PartitionRegion& cluster_pr, const PartitionRegion& new_pr);
64+
5165
private:
5266
std::vector<Region> partition_region; ///< union of rectangular regions that a partition can be placed in
5367
};

vpr/src/pack/cluster.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,6 @@ static enum e_block_pack_status atom_cluster_floorplanning_check(const AtomBlock
17351735

17361736
PartitionRegion atom_pr;
17371737
PartitionRegion cluster_pr;
1738-
PartitionRegion intersect_pr;
17391738

17401739
//if the atom does not belong to a partition, it can be put in the cluster
17411740
//regardless of what the cluster's PartitionRegion is because it has no constraints
@@ -1760,18 +1759,20 @@ static enum e_block_pack_status atom_cluster_floorplanning_check(const AtomBlock
17601759
}
17611760
return BLK_PASSED;
17621761
} else {
1763-
intersect_pr = intersection(cluster_pr, atom_pr);
1762+
//update cluster_pr with the intersection of the cluster's PartitionRegion
1763+
//and the atom's PartitionRegion
1764+
update_cluster_part_reg(cluster_pr, atom_pr);
17641765
}
17651766

1766-
if (intersect_pr.empty() == true) {
1767+
if (cluster_pr.empty() == true) {
17671768
if (verbosity > 3) {
17681769
VTR_LOG("\t\t\t Intersect: Atom block %d failed floorplanning check for cluster %d \n", blk_id, clb_index);
17691770
}
17701771
cluster_pr_needs_update = false;
17711772
return BLK_FAILED_FLOORPLANNING;
17721773
} else {
17731774
//update the cluster's PartitionRegion with the intersecting PartitionRegion
1774-
temp_cluster_pr = intersect_pr;
1775+
temp_cluster_pr = cluster_pr;
17751776
cluster_pr_needs_update = true;
17761777
if (verbosity > 3) {
17771778
VTR_LOG("\t\t\t Intersect: Atom block %d passed cluster %d, cluster PR was updated with intersection result \n", blk_id, clb_index);

vpr/src/place/place_constraints.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "region.h"
1010
#include "clustered_netlist_utils.h"
1111

12-
1312
#ifndef VPR_SRC_PLACE_PLACE_CONSTRAINTS_H_
1413
# define VPR_SRC_PLACE_PLACE_CONSTRAINTS_H_
1514

0 commit comments

Comments
 (0)