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 2 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
6 changes: 1 addition & 5 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 Expand Up @@ -406,8 +404,6 @@ static DeviceGrid build_device_grid(const t_grid_def& grid_def, size_t grid_widt
size_t incry = p.parse_formula(yspec.incr_expr, vars);
size_t repeaty = p.parse_formula(yspec.repeat_expr, vars);

warn_out_of_range = false;

//Check start against the device dimensions
// Start locations outside the device will never create block instances
if (startx > grid_width - 1) {
Expand Down
13 changes: 7 additions & 6 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 @@ -71,14 +75,11 @@ void echo_constraints(char* filename, VprConstraints constraints) {
FILE* fp;
fp = vtr::fopen(filename, "w");

int num_of_parts = constraints.get_num_partitions();

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

fclose(fp);
}
53 changes: 43 additions & 10 deletions vpr/src/pack/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* clu
int verbosity,
bool enable_pin_feasibility_filter,
const int feasible_block_array_size,
t_ext_pin_util max_external_pin_util);
t_ext_pin_util max_external_pin_util,
PartitionRegion& temp_cluster_pr);

static enum e_block_pack_status try_place_atom_block_rec(const t_pb_graph_node* pb_graph_node,
const AtomBlockId blk_id,
Expand Down Expand Up @@ -276,7 +277,8 @@ static void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats
int verbosity,
bool enable_pin_feasibility_filter,
bool balance_block_type_utilization,
const int feasible_block_array_size);
const int feasible_block_array_size,
PartitionRegion& temp_cluster_pr);

static t_pack_molecule* get_highest_gain_molecule(t_pb* cur_pb,
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
Expand Down Expand Up @@ -572,6 +574,10 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa

VTR_LOGV(verbosity > 2, "Complex block %d:\n", num_clb);

/*this temp structure is used to store updates to the cluster's
* floorplanning constraints before they are stored long-term*/
PartitionRegion temp_cluster_pr;

start_new_cluster(cluster_placement_stats, primitives_list,
atom_molecules, clb_index, istart,
num_used_type_instances,
Expand All @@ -584,7 +590,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
packer_opts.pack_verbosity,
packer_opts.enable_pin_feasibility_filter,
balance_block_type_utilization,
packer_opts.feasible_block_array_size);
packer_opts.feasible_block_array_size,
temp_cluster_pr);

//initial molecule in cluster has been processed
num_molecules_processed++;
Expand Down Expand Up @@ -649,7 +656,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
packer_opts.pack_verbosity,
packer_opts.enable_pin_feasibility_filter,
packer_opts.feasible_block_array_size,
target_ext_pin_util);
target_ext_pin_util,
temp_cluster_pr);
prev_molecule = next_molecule;

auto blk_id = next_molecule->atom_block_ids[next_molecule->root];
Expand Down Expand Up @@ -1288,7 +1296,8 @@ static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* clu
int verbosity,
bool enable_pin_feasibility_filter,
const int feasible_block_array_size,
t_ext_pin_util max_external_pin_util) {
t_ext_pin_util max_external_pin_util,
PartitionRegion& temp_cluster_pr) {
int molecule_size, failed_location;
int i;
enum e_block_pack_status block_pack_status;
Expand Down Expand Up @@ -1327,7 +1336,6 @@ static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* clu
return BLK_FAILED_FEASIBLE;
}

PartitionRegion temp_cluster_pr;
bool cluster_pr_needs_update = false;

//check if every atom in the molecule is legal in the cluster from a floorplanning perspective
Expand Down Expand Up @@ -1447,8 +1455,6 @@ static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* clu
}

//update cluster PartitionRegion if atom with floorplanning constraints was added
/* TODO: Create temp_cluster_pr in start_new_cluster and pass to this function
* by reference so that this check is not needed */
if (cluster_pr_needs_update) {
floorplanning_ctx.cluster_constraints[clb_index] = temp_cluster_pr;
if (verbosity > 2) {
Expand Down Expand Up @@ -2132,7 +2138,8 @@ static void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats
int verbosity,
bool enable_pin_feasibility_filter,
bool balance_block_type_utilization,
const int feasible_block_array_size) {
const int feasible_block_array_size,
PartitionRegion& temp_cluster_pr) {
/* Given a starting seed block, start_new_cluster determines the next cluster type to use
* It expands the FPGA if it cannot find a legal cluster for the atom block
*/
Expand Down Expand Up @@ -2218,7 +2225,8 @@ static void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats
verbosity,
enable_pin_feasibility_filter,
feasible_block_array_size,
FULL_EXTERNAL_PIN_UTIL);
FULL_EXTERNAL_PIN_UTIL,
temp_cluster_pr);

success = (pack_result == BLK_PASSED);
}
Expand Down Expand Up @@ -2633,6 +2641,31 @@ static void echo_clusters(char* filename) {
}
}

fprintf(fp, "\nCLUSTER CONSTRAINTS:\n");
auto& floorplanning_ctx = g_vpr_ctx.mutable_floorplanning();

for (ClusterBlockId clb_id : cluster_ctx.clb_nlist.blocks()) {
std::vector<Region> reg = floorplanning_ctx.cluster_constraints[clb_id].get_partition_region();
if (reg.size() != 0) {
fprintf(fp, "\nRegions in Cluster %zu:\n", size_t(clb_id));
for (unsigned int i = 0; i < reg.size(); i++) {
vtr::Rect<int> rect = reg[i].get_region_rect();
int xmin = rect.xmin();
int xmax = rect.xmax();
int ymin = rect.ymin();
int ymax = rect.ymax();
int subtile = reg[i].get_sub_tile();

fprintf(fp, "\tRegion: \n");
fprintf(fp, "\txmin: %d\n", xmin);
fprintf(fp, "\tymin: %d\n", ymin);
fprintf(fp, "\txmax: %d\n", xmax);
fprintf(fp, "\tymax: %d\n", ymax);
fprintf(fp, "\tsubtile: %d\n\n", subtile);
}
}
}

fclose(fp);
}

Expand Down