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 5 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
2 changes: 2 additions & 0 deletions vpr/src/base/SetupGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ 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
8 changes: 5 additions & 3 deletions vpr/src/base/constraints_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,18 @@ 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");

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_parts);
print_constraints(fp, constraints, num_parts);
fprintf(fp, "\n Number of partitions is %d \n", num_of_parts);
print_constraints(fp, constraints, num_of_parts);

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
2 changes: 1 addition & 1 deletion vpr/src/base/vpr_constraints_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ void load_vpr_constraints_file(const char* read_vpr_constraints_name) {
VprConstraints ctx_constraints = floorplanning_ctx.constraints;

if (getEchoEnabled() && isEchoFileEnabled(E_ECHO_VPR_CONSTRAINTS)) {
echo_constraints(getEchoFileName(E_ECHO_VPR_CONSTRAINTS), ctx_constraints, ctx_constraints.get_num_partitions());
echo_constraints(getEchoFileName(E_ECHO_VPR_CONSTRAINTS), ctx_constraints);
}
}
4 changes: 4 additions & 0 deletions vpr/src/base/vpr_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ struct FloorplanningContext : public Context {
*
* 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;

Expand All @@ -391,6 +393,8 @@ struct FloorplanningContext : public Context {
* 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;
};
Expand Down
79 changes: 63 additions & 16 deletions vpr/src/pack/cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,14 @@ static t_pack_molecule* get_molecule_by_num_ext_inputs(const int ext_inps,
static t_pack_molecule* get_free_molecule_with_most_ext_inputs_for_cluster(t_pb* cur_pb,
t_cluster_placement_stats* cluster_placement_stats_ptr);

static void print_pack_status_header();

static void print_pack_status(int num_clb,
int tot_num_molecules,
int num_molecules_processed,
std::map<t_logical_block_type_ptr, size_t> clb_types);
int& mols_since_last_print,
int device_width,
int device_height);

static enum e_block_pack_status try_pack_molecule(t_cluster_placement_stats* cluster_placement_stats_ptr,
const std::multimap<AtomBlockId, t_pack_molecule*>& atom_molecules,
Expand Down Expand Up @@ -401,15 +405,16 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
*****************************************************************/
VTR_ASSERT(packer_opts.packer_algorithm == PACK_GREEDY);

int num_molecules, num_molecules_processed, blocks_since_last_analysis, num_clb,
num_blocks_hill_added, max_cluster_size, cur_cluster_size,
int num_molecules, num_molecules_processed, mols_since_last_print, blocks_since_last_analysis,
num_clb, num_blocks_hill_added, max_cluster_size, cur_cluster_size,
max_pb_depth, cur_pb_depth, num_unrelated_clustering_attempts,
seedindex, savedseedindex /* index of next most timing critical block */,
detailed_routing_stage, *hill_climbing_inputs_avail;

const int verbosity = packer_opts.pack_verbosity;

num_molecules_processed = 0;
mols_since_last_print = 0;

std::map<t_logical_block_type_ptr, size_t> num_used_type_instances;

Expand Down Expand Up @@ -553,6 +558,8 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa

istart = get_highest_gain_seed_molecule(&seedindex, atom_molecules, seed_atoms);

print_pack_status_header();

/****************************************************************
* Clustering
*****************************************************************/
Expand Down Expand Up @@ -581,6 +588,13 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa

//initial molecule in cluster has been processed
num_molecules_processed++;
mols_since_last_print++;
print_pack_status(num_clb,
num_molecules,
num_molecules_processed,
mols_since_last_print,
device_ctx.grid.width(),
device_ctx.grid.height());

VTR_LOGV(verbosity > 2,
"Complex block %d: '%s' (%s) ", num_clb,
Expand Down Expand Up @@ -689,6 +703,12 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa

//Since molecule passed, update num_molecules_processed
num_molecules_processed++;
mols_since_last_print++;
print_pack_status(num_clb, num_molecules,
num_molecules_processed,
mols_since_last_print,
device_ctx.grid.width(),
device_ctx.grid.height());

update_cluster_stats(next_molecule, clb_index,
is_clock, //Set of all clocks
Expand Down Expand Up @@ -762,7 +782,7 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
update_le_count(cur_pb, logic_block_type, le_pb_type, le_count);

//print clustering progress incrementally
print_pack_status(num_clb, num_molecules, num_molecules_processed, num_used_type_instances);
//print_pack_status(num_clb, num_molecules, num_molecules_processed, mols_since_last_print, device_ctx.grid.width(), device_ctx.grid.height());

free_pb_stats_recursive(cur_pb);
} else {
Expand Down Expand Up @@ -820,20 +840,44 @@ std::map<t_logical_block_type_ptr, size_t> do_clustering(const t_packer_opts& pa
return num_used_type_instances;
}

/*print the header for the clustering progress table*/
static void print_pack_status_header() {
VTR_LOG("Starting Clustering - Clustering Progress: \n");
VTR_LOG("------------------- -------------------------- ---------\n");
VTR_LOG("Molecules processed Number of clusters created FPGA size\n");
VTR_LOG("------------------- -------------------------- ---------\n");
}

/*incrementally print progress updates during clustering*/
static void print_pack_status(int num_clb,
int tot_num_molecules,
int num_molecules_processed,
std::map<t_logical_block_type_ptr, size_t> clb_types) {
//print an update every 10 clusters
if (num_clb % 50 == 0) {
VTR_LOG("\nCreated %d clusters\n", num_clb);
VTR_LOG("Processed %d out of %d molecules\n", num_molecules_processed, tot_num_molecules);
VTR_LOG("Cluster types:\n");
int& mols_since_last_print,
int device_width,
int device_height) {
const float print_frequency = 0.04;

double percentage = (num_molecules_processed / (double)tot_num_molecules) * 100;

int int_percentage = int(percentage);

int int_molecule_increment = (int)(print_frequency * tot_num_molecules);

if (mols_since_last_print == int_molecule_increment) {
VTR_LOG(
"%6d/%-6d %3d%% "
"%26d "
"%3d x %-3d ",
num_molecules_processed,
tot_num_molecules,
int_percentage,
num_clb,
device_width,
device_height);

for (auto i = clb_types.begin(); i != clb_types.end(); i++) {
VTR_LOG("\t %s: # blocks %zu \n", i->first->name, size_t(i->second));
}
VTR_LOG("\n");
fflush(stdout);
mols_since_last_print = 0;
}
}

Expand Down Expand Up @@ -1403,9 +1447,13 @@ 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;
VTR_LOG("\nUpdated PartitionRegion of cluster %d\n", clb_index);
if (verbosity > 2) {
VTR_LOG("\nUpdated PartitionRegion of cluster %d\n", clb_index);
}
}

for (i = 0; i < molecule_size; i++) {
Expand Down Expand Up @@ -2225,8 +2273,6 @@ static void start_new_cluster(t_cluster_placement_stats* cluster_placement_stats

if (num_used_type_instances[block_type] > num_instances) {
device_ctx.grid = create_device_grid(device_layout_name, arch->grid_layouts, num_used_type_instances, target_device_utilization);
VTR_LOGV(verbosity > 0, "Not enough resources expand FPGA size to (%d x %d)\n",
device_ctx.grid.width(), device_ctx.grid.height());
}
}

Expand Down Expand Up @@ -2548,6 +2594,7 @@ static void check_clustering() {
}
}

/*Print the contents of each cluster to an echo file*/
static void echo_clusters(char* filename) {
FILE* fp;
fp = vtr::fopen(filename, "w");
Expand Down
1 change: 1 addition & 0 deletions vpr/src/pack/output_clustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ static void print_stats() {
}

static void print_clustering_stats_header() {
VTR_LOG("Final Clustering Statistics: \n");
VTR_LOG("---------- -------- ------------------------------------ --------------------------\n");
VTR_LOG("Block Type # Blocks Avg. # of input clocks and pins used Avg. # of output pins used\n");
VTR_LOG("---------- -------- ------------------------------------ --------------------------\n");
Expand Down