Skip to content

Clusterer feasibility changes #1641

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 35 commits into from
Feb 27, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
918219f
Added a vpr floorplanning constraints context
sfkhalid Dec 16, 2020
1fdf881
Wrote code to set the PartitionRegion of the new cluster in start_new…
sfkhalid Jan 18, 2021
ca7b577
Added code to check for an empty PartitionRegion and code to check in…
sfkhalid Jan 21, 2021
ed6e7a8
Modified function for intersecting atom and cluster PartitionRegions
sfkhalid Jan 21, 2021
532a143
Fixed bug where cluster PartitionRegion was not updated soon enough i…
sfkhalid Jan 25, 2021
511a994
Ran make format
sfkhalid Jan 26, 2021
8008b2e
Added function to echo cluster contents
sfkhalid Jan 27, 2021
54f4995
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Jan 27, 2021
5845338
Added routine print_pack_status to print some cluster stats increment…
sfkhalid Jan 27, 2021
7b465fe
Printed end of clustering stats in table format
sfkhalid Jan 28, 2021
6fb45ff
Shortened and clarified some comments
sfkhalid Jan 28, 2021
3a606e8
Made formatting changes to cluster echo file
sfkhalid Jan 28, 2021
4fceb1e
Changed frequency of cluster progress messages
sfkhalid Feb 1, 2021
f00d55d
Need to merge changes to be able to push to remote branch. Merge bran…
sfkhalid Feb 1, 2021
f34a1d6
Changed data structure for holding cluster constraints from unordered…
sfkhalid Feb 3, 2021
e4b8257
Changed place where cluster's PartitionRegion is updated so that it d…
sfkhalid Feb 3, 2021
6e59e42
Added comments and removed unnecessary variables
sfkhalid Feb 4, 2021
ffa49a1
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Feb 4, 2021
83cfe2b
Made packing progress print every 4%
sfkhalid Feb 8, 2021
ed0cd07
Need to update local branchMerge branch 'clusterer_feasibility_change…
sfkhalid Feb 8, 2021
7e8f9d5
Print clustering progress in a table
sfkhalid Feb 8, 2021
c8b58b8
Added function level comments and table headers
sfkhalid Feb 8, 2021
f11da67
Modified build_device_grid function call in SetupGrid.cpp to get rid …
sfkhalid Feb 10, 2021
899a3da
Create the temporary cluster PartitionRegion earlier in the flow when…
sfkhalid Feb 10, 2021
afcb926
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Feb 11, 2021
ee4bf86
Moved print functions to be within their respective class. ex - print…
sfkhalid Feb 12, 2021
37ef5a7
Merge origin with local to be able to push changes to local 'clustere…
sfkhalid Feb 12, 2021
cfb812f
Comment update for print_constraints function
sfkhalid Feb 12, 2021
e2a7bfc
Updated comment for echo_constraints function
sfkhalid Feb 12, 2021
680cbdc
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Feb 15, 2021
40e9534
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Feb 26, 2021
d2d6fcb
Updated PartitionRegion class comment
sfkhalid Feb 26, 2021
bd217bf
Need to run make format on changes that were merged remotely 'cluster…
sfkhalid Feb 26, 2021
8c5bc25
Ran make format to fix formatting in vtr geometry file
sfkhalid Feb 26, 2021
b807f83
Merge branch 'master' into clusterer_feasibility_changes
sfkhalid Feb 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions vpr/src/base/SetupGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ static DeviceGrid auto_size_device_grid(const std::vector<t_grid_def>& grid_layo
//Check if it satisfies the block counts
if (grid_satisfies_instance_counts(grid, minimum_instance_counts, maximum_device_utilization)) {
//Re-build the grid at the final size with out-of-range
//warnings turned on (so users are aware of out-of-range issues
//at the final device sizes)
grid = build_device_grid(grid_def, width, height, true, limiting_resources);
grid = build_device_grid(grid_def, width, height, false, limiting_resources);
return grid;
}

Expand Down
13 changes: 8 additions & 5 deletions vpr/src/base/constraints_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
static void print_region(FILE* fp, Region region);
static void print_partition(FILE* fp, Partition part);
static void print_partition_region(FILE* fp, PartitionRegion pr);
static void print_constraints(FILE* fp, VprConstraints constraints, int num_parts);
static void print_constraints(FILE* fp, VprConstraints constraints);

void print_region(FILE* fp, Region region) {
vtr::Rect<int> rect = region.get_region_rect();
Expand Down Expand Up @@ -42,10 +42,14 @@ void print_partition_region(FILE* fp, PartitionRegion pr) {
}
}

void print_constraints(FILE* fp, VprConstraints constraints, int num_parts) {
void print_constraints(FILE* fp, VprConstraints constraints) {
Partition temp_part;
std::vector<AtomBlockId> atoms;

int num_parts = constraints.get_num_partitions();

fprintf(fp, "\n Number of partitions is %d \n", num_parts);

for (int i = 0; i < num_parts; i++) {
PartitionId part_id(i);

Expand All @@ -67,16 +71,15 @@ void print_constraints(FILE* fp, VprConstraints constraints, int num_parts) {
}
}

void echo_constraints(char* filename, VprConstraints constraints, int num_parts) {
void echo_constraints(char* filename, VprConstraints constraints) {
FILE* fp;
fp = vtr::fopen(filename, "w");

fprintf(fp, "--------------------------------------------------------------\n");
fprintf(fp, "Constraints\n");
fprintf(fp, "--------------------------------------------------------------\n");
fprintf(fp, "\n");
fprintf(fp, "\n Number of partitions is %d \n", num_parts);
print_constraints(fp, constraints, num_parts);
print_constraints(fp, constraints);

fclose(fp);
}
2 changes: 1 addition & 1 deletion vpr/src/base/constraints_load.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
#include "vpr_constraints.h"
#include "vtr_vector.h"

void echo_constraints(char* filename, VprConstraints constraints, int num_parts);
void echo_constraints(char* filename, VprConstraints constraints);

#endif
3 changes: 3 additions & 0 deletions vpr/src/base/echo_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ void alloc_and_load_echo_file_info() {
//Vpr constraints
setEchoFileName(E_ECHO_VPR_CONSTRAINTS, "vpr_constraints.echo");

//Packing
setEchoFileName(E_ECHO_CLUSTERS, "clusters.echo");

//Intra-block routing
setEchoFileName(E_ECHO_INTRA_LB_FAILED_ROUTE, "intra_lb_failed_route.echo");

Expand Down
3 changes: 3 additions & 0 deletions vpr/src/base/echo_files.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ enum e_echo_files {
E_ECHO_PRE_PACKING_MOLECULES_AND_PATTERNS,
E_ECHO_VPR_CONSTRAINTS,

//Packing
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At top, file controls echo files, we have an enum to each one, search for in code to see what each one prints

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

say what echo files are, what they are used for - dumps that intended to be written and read by a developer, typically direct reps of data structures to make debugging easier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum e_output_files - line 66 - see what these are in code and leave a brief comment, or make an issue saying this may just be same as other enum and we should just put them both together

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set an issue to clean up these two enums (either just need to comment, or merge the two diff enums)
whole thing could be wrapped in a class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

echo file name can maybe also take a default name (person can choose to pass it in - if not, default set to null), the set_output_filename would work fore everything

investigate - is there some other reason to have the second output enum? - look at the call sites for that

in the cpp file -> instead of the mallocs, recode using c++ strings and wrap it all in a class

-> all the members of the class could be static members (don't have to turn into class, see if it's worth it) (make a member object of the echo class in something like the vpr_options file)

  • might be better to not have class, either way clean up the code by getting rid of mallocs and use c++ strings

E_ECHO_CLUSTERS,

// Intra-block routing
E_ECHO_INTRA_LB_FAILED_ROUTE,

Expand Down
4 changes: 4 additions & 0 deletions vpr/src/base/partition_region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ std::vector<Region> PartitionRegion::get_partition_region() {
return partition_region;
}

bool PartitionRegion::empty() {
return partition_region.size() == 0;
}

PartitionRegion intersection(PartitionRegion& pr1, PartitionRegion& pr2) {
/**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
Expand Down
5 changes: 5 additions & 0 deletions vpr/src/base/partition_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class PartitionRegion {
*/
std::vector<Region> get_partition_region();

/**
* @brief Check if the PartitionRegion is empty (meaning there is no constraint on the object the PartitionRegion belongs to)
*/
bool empty();

/**
* @brief Global friend function that returns the intersection of two PartitionRegions
*
Expand Down
10 changes: 10 additions & 0 deletions vpr/src/base/vpr_constraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,13 @@ std::vector<AtomBlockId> VprConstraints::get_part_atoms(PartitionId part_id) {

return part_atoms;
}

int VprConstraints::get_num_partitions() {
return partitions.size();
}

PartitionRegion VprConstraints::get_partition_pr(PartitionId part_id) {
PartitionRegion pr;
pr = partitions[part_id].get_part_region();
return pr;
}
29 changes: 28 additions & 1 deletion vpr/src/base/vpr_constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
* It also specifies which regions the partitions should be placed in. Atoms cannot be placed in more than one partition.
* If an atom is assigned to more than one partition, the last partition is was assigned to will be the partition it is placed in.
*
* Related Classes
* ===============
* The following definitions are useful to understanding this class:
*
* Partition: a grouping of atoms that are constrained to a portion of an FPGA
* See vpr/base/partition.h for more detail
*
* Region: the x and y bounds of a rectangular region, optionally including a subtile value,
* that atoms in a partition are constrained to
* See vpr/base/region.h for more detail
*
* PartitionRegion: the union of regions that a partition can be placed in
* See vpr/base/partition_region.h for more detail
*
*
*/

class VprConstraints {
Expand All @@ -33,7 +48,7 @@ class VprConstraints {
/**
* @brief Return id of the partition the atom belongs to
*
* If an atom is not in a partition (unconstrained), PartitionId::Invalid() is returned.
* If an atom is not in a partition (unconstrained), PartitionId::INVALID() is returned.
*
* @param blk_id The atom for which the partition id is needed
*/
Expand All @@ -60,6 +75,18 @@ class VprConstraints {
*/
std::vector<AtomBlockId> get_part_atoms(PartitionId part_id);

/**
* @brief Returns the number of partitions in the object
*/
int get_num_partitions();

/**
* @brief Returns the PartitionRegion belonging to the specified Partition
*
* @param part_id The id of the partition whose PartitionRegion is needed
*/
PartitionRegion get_partition_pr(PartitionId part_id);

private:
/**
* Store all constrained atoms
Expand Down
9 changes: 6 additions & 3 deletions vpr/src/base/vpr_constraints_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ void load_vpr_constraints_file(const char* read_vpr_constraints_name) {
read_vpr_constraints_name);
}

VprConstraints constraints = reader.constraints_;
int num_parts = reader.num_partitions_;
//Update the floorplanning constraints in the floorplanning constraints context
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();
floorplanning_ctx.constraints = reader.constraints_;

VprConstraints ctx_constraints = floorplanning_ctx.constraints;

if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_VPR_CONSTRAINTS)) {
echo_constraints(getEchoFileName(E_ECHO_VPR_CONSTRAINTS), constraints, num_parts);
echo_constraints(getEchoFileName(E_ECHO_VPR_CONSTRAINTS), ctx_constraints);
}
}
34 changes: 34 additions & 0 deletions vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "place_macro.h"
#include "compressed_grid.h"
#include "metadata_storage.h"
#include "vpr_constraints.h"

/**
* @brief A Context is collection of state relating to a particular part of VPR
Expand Down Expand Up @@ -369,6 +370,35 @@ struct RoutingContext : public Context {
cached_router_lookahead_;
};

/**
* @brief State relating to VPR's floorplanning constraints
*
* This should contain only data structures related to constraining blocks
* to certain regions on the chip.
*/
struct FloorplanningContext : public Context {
/**
* @brief Stores groups of constrained atoms, areas where the atoms are constrained to
*
* Provides all information needed about floorplanning constraints, including
* which atoms are constrained and the regions they are constrained to.
*
* The constraints are input into vpr and do not change.
*/
VprConstraints constraints;

/**
* @brief Constraints for each cluster
*
* Each cluster will have a PartitionRegion specifying its regions constraints
* according to the constrained atoms packed into it. This structure allows the floorplanning
* constraints for a given cluster to be found easily given its ClusterBlockId.
*
* The constraints on each cluster are computed during the clustering process and can change.
*/
vtr::vector<ClusterBlockId, PartitionRegion> cluster_constraints;
};

/**
* @brief This object encapsulates VPR's state.
*
Expand Down Expand Up @@ -440,6 +470,9 @@ class VprContext : public Context {
const RoutingContext& routing() const { return routing_; }
RoutingContext& mutable_routing() { return routing_; }

const FloorplanningContext& floorplanning() const { return constraints_; }
FloorplanningContext& mutable_floorplanning() { return constraints_; }

private:
DeviceContext device_;

Expand All @@ -451,6 +484,7 @@ class VprContext : public Context {
ClusteringContext clustering_;
PlacementContext placement_;
RoutingContext routing_;
FloorplanningContext constraints_;
};

#endif
1 change: 1 addition & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ enum e_block_pack_status {
BLK_PASSED,
BLK_FAILED_FEASIBLE,
BLK_FAILED_ROUTE,
BLK_FAILED_FLOORPLANNING,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think about whether this enum can be in a lower header file. If it's only used in the clusterer, can have a cluster_utilities header file and put this enum in there. This can be a cleanup on a separate pull request

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in pack subdirectory - is there a cluster utilities type header file? check, could possibly put there

BLK_STATUS_UNDEFINED
};

Expand Down
Loading