Skip to content

Commit

Permalink
Merge pull request #2771 from AlexandreSinger/feature-verify-clustering
Browse files Browse the repository at this point in the history
[Clustering] Independent Clustering Verification
  • Loading branch information
AlexandreSinger authored Nov 7, 2024
2 parents 045a9e8 + 58ea2c0 commit 1876d05
Show file tree
Hide file tree
Showing 4 changed files with 568 additions and 18 deletions.
13 changes: 13 additions & 0 deletions vpr/src/analytical_place/full_legalizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "physical_types.h"
#include "place_constraints.h"
#include "place_macro.h"
#include "verify_clustering.h"
#include "verify_placement.h"
#include "vpr_api.h"
#include "vpr_context.h"
Expand Down Expand Up @@ -392,6 +393,18 @@ void FullLegalizer::legalize(const PartialPlacement& p_placement) {

// Pack the atoms into clusters based on the partial placement.
create_clusters(p_placement);
// Verify that the clustering created by the full legalizer is valid.
unsigned num_clustering_errors = verify_clustering(g_vpr_ctx);
if (num_clustering_errors == 0) {
VTR_LOG("Completed clustering consistency check successfully.\n");
} else {
VPR_ERROR(VPR_ERROR_AP,
"Completed placement consistency check, %u errors found.\n"
"Aborting program.\n",
num_clustering_errors);
}
// Get the clustering from the global context.
// TODO: Eventually should be returned from the create_clusters method.
const ClusteredNetlist& clb_nlist = g_vpr_ctx.clustering().clb_nlist;

// Place the clusters based on where the atoms want to be placed.
Expand Down
44 changes: 26 additions & 18 deletions vpr/src/base/vpr_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "place_util.h"
#include "timing_fail_error.h"
#include "analytical_placement_flow.h"
#include "verify_clustering.h"

#include "vpr_constraints_writer.h"

Expand Down Expand Up @@ -622,34 +623,16 @@ bool vpr_pack_flow(t_vpr_setup& vpr_setup, const t_arch& arch) {

// generate a .net file by legalizing an input flat placement file
if (packer_opts.load_flat_placement) {

//Load and legalizer flat placement file
vpr_load_flat_placement(vpr_setup, arch);

//Load the result from the .net file
vpr_load_packing(vpr_setup, arch);

} else {

//Load a previous packing from the .net file
vpr_load_packing(vpr_setup, arch);

}

}

// Load cluster_constraints data structure.
load_cluster_constraints();

/* Sanity check the resulting netlist */
check_netlist(packer_opts.pack_verbosity);

/* Output the netlist stats to console and optionally to file. */
writeClusteredNetlistStats(vpr_setup.FileNameOpts.write_block_usage);

// print the total number of used physical blocks for each
// physical block type after finishing the packing stage
print_pb_type_count(g_vpr_ctx.clustering().clb_nlist);
}

return status;
Expand Down Expand Up @@ -742,6 +725,31 @@ void vpr_load_packing(t_vpr_setup& vpr_setup, const t_arch& arch) {
std::ofstream ofs("packing_pin_util.rpt");
report_packing_pin_usage(ofs, g_vpr_ctx);
}

// Load cluster_constraints data structure.
load_cluster_constraints();

/* Sanity check the resulting netlist */
check_netlist(vpr_setup.PackerOpts.pack_verbosity);

// Independently verify the clusterings to ensure the clustering can be
// used for the rest of the VPR flow.
unsigned num_errors = verify_clustering(g_vpr_ctx);
if (num_errors == 0) {
VTR_LOG("Completed clustering consistency check successfully.\n");
} else {
VPR_ERROR(VPR_ERROR_PACK,
"%u errors found while performing clustering consistency "
"check. Aborting program.\n",
num_errors);
}

/* Output the netlist stats to console and optionally to file. */
writeClusteredNetlistStats(vpr_setup.FileNameOpts.write_block_usage);

// print the total number of used physical blocks for each
// physical block type after finishing the packing stage
print_pb_type_count(g_vpr_ctx.clustering().clb_nlist);
}

bool vpr_load_flat_placement(t_vpr_setup& vpr_setup, const t_arch& arch) {
Expand Down
Loading

0 comments on commit 1876d05

Please sign in to comment.