From 1ae9f51dbd49eb4810c2e88134565603ee108e21 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Thu, 25 Jul 2024 19:55:30 -0400 Subject: [PATCH 1/6] [vpr][base] add read init place --- vpr/src/base/SetupVPR.cpp | 2 ++ vpr/src/base/read_options.cpp | 5 +++++ vpr/src/base/read_options.h | 1 + vpr/src/base/vpr_types.h | 1 + 4 files changed, 9 insertions(+) diff --git a/vpr/src/base/SetupVPR.cpp b/vpr/src/base/SetupVPR.cpp index d05f7d5d7da..aa3056efc75 100644 --- a/vpr/src/base/SetupVPR.cpp +++ b/vpr/src/base/SetupVPR.cpp @@ -639,6 +639,8 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts) PlacerOpts->write_initial_place_file = Options.write_initial_place_file; + PlacerOpts->read_initial_place_file = Options.read_initial_place_file; + PlacerOpts->pad_loc_type = Options.pad_loc_type; PlacerOpts->place_chan_width = Options.PlaceChanWidth; diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index f14bb940b28..e90862ac6e7 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1632,6 +1632,11 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .metavar("INITIAL_PLACE_FILE") .show_in(argparse::ShowIn::HELP_ONLY); + file_grp.add_argument(args.read_initial_place_file, "--read_initial_place_file") + .help("Writes out the the placement chosen by the initial placement algorithm to the specified file") + .metavar("INITIAL_PLACE_FILE") + .show_in(argparse::ShowIn::HELP_ONLY); + file_grp.add_argument(args.read_vpr_constraints_file, "--read_vpr_constraints") .help("Reads the floorplanning constraints that packing and placement must respect from the specified XML file.") .show_in(argparse::ShowIn::HELP_ONLY); diff --git a/vpr/src/base/read_options.h b/vpr/src/base/read_options.h index a2dcc49d244..dbdced6cfa6 100644 --- a/vpr/src/base/read_options.h +++ b/vpr/src/base/read_options.h @@ -29,6 +29,7 @@ struct t_options { argparse::ArgValue write_rr_graph_file; argparse::ArgValue read_rr_graph_file; argparse::ArgValue write_initial_place_file; + argparse::ArgValue read_initial_place_file; argparse::ArgValue read_vpr_constraints_file; argparse::ArgValue write_vpr_constraints_file; argparse::ArgValue write_constraints_file; diff --git a/vpr/src/base/vpr_types.h b/vpr/src/base/vpr_types.h index fe0a8fb4658..e556d0eed17 100644 --- a/vpr/src/base/vpr_types.h +++ b/vpr/src/base/vpr_types.h @@ -1236,6 +1236,7 @@ struct t_placer_opts { enum e_pad_loc_type pad_loc_type; std::string constraints_file; std::string write_initial_place_file; + std::string read_initial_place_file; enum pfreq place_freq; int recompute_crit_iter; int inner_loop_recompute_divider; From d20f16229abe0d95287a497fa2466037c0252c51 Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 26 Jul 2024 19:22:40 -0400 Subject: [PATCH 2/6] [vpr][place] remove adding .place.init from the init place file --- vpr/src/place/place.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vpr/src/place/place.cpp b/vpr/src/place/place.cpp index 134ff8fb772..7259729d4d4 100644 --- a/vpr/src/place/place.cpp +++ b/vpr/src/place/place.cpp @@ -462,7 +462,7 @@ void try_place(const Netlist<>& net_list, if (!placer_opts.write_initial_place_file.empty()) { print_place(nullptr, nullptr, - (placer_opts.write_initial_place_file + ".init.place").c_str()); + (placer_opts.write_initial_place_file).c_str()); } #ifdef ENABLE_ANALYTIC_PLACE From dad74029752ae5b863182dabaeb9f2a44a98ae3e Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 26 Jul 2024 19:25:28 -0400 Subject: [PATCH 3/6] [vpr][place] read initial placement from a file --- vpr/src/place/initial_placement.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/vpr/src/place/initial_placement.cpp b/vpr/src/place/initial_placement.cpp index 2b4f9bfdf4f..f6e2348d385 100644 --- a/vpr/src/place/initial_placement.cpp +++ b/vpr/src/place/initial_placement.cpp @@ -1187,12 +1187,12 @@ void initial_placement(const t_placer_opts& placer_opts, clear_all_grid_locs(); /* Go through cluster blocks to calculate the tightest placement - * floorplan constraint for each constrained block - */ + * floorplan constraint for each constrained block + */ propagate_place_constraints(); /*Mark the blocks that have already been locked to one spot via floorplan constraints - * as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement*/ + * as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement*/ mark_fixed_blocks(); // Compute and store compressed floorplanning constraints @@ -1204,17 +1204,22 @@ void initial_placement(const t_placer_opts& placer_opts, read_constraints(constraints_file); } - if (noc_opts.noc) { - // NoC routers are placed before other blocks - initial_noc_placement(noc_opts, placer_opts); - propagate_place_constraints(); - } + if(!placer_opts.read_initial_place_file.empty()) { + const auto& grid = g_vpr_ctx.device().grid; + read_place(nullptr, placer_opts.read_initial_place_file.c_str(), false, grid); + } else { + if (noc_opts.noc) { + // NoC routers are placed before other blocks + initial_noc_placement(noc_opts, placer_opts); + propagate_place_constraints(); + } - //Assign scores to blocks and placement macros according to how difficult they are to place - vtr::vector block_scores = assign_block_scores(); + //Assign scores to blocks and placement macros according to how difficult they are to place + vtr::vector block_scores = assign_block_scores(); - //Place all blocks - place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file); + //Place all blocks + place_all_blocks(placer_opts, block_scores, placer_opts.pad_loc_type, constraints_file); + } alloc_and_load_movable_blocks(); From eb3263582963e83e2ec2662253ce37348bb4e28c Mon Sep 17 00:00:00 2001 From: amin1377 Date: Fri, 26 Jul 2024 19:34:17 -0400 Subject: [PATCH 4/6] [vpr][base] fix CLI doc --- vpr/src/base/read_options.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vpr/src/base/read_options.cpp b/vpr/src/base/read_options.cpp index e90862ac6e7..e1d2b16a6b7 100644 --- a/vpr/src/base/read_options.cpp +++ b/vpr/src/base/read_options.cpp @@ -1633,7 +1633,7 @@ argparse::ArgumentParser create_arg_parser(const std::string& prog_name, t_optio .show_in(argparse::ShowIn::HELP_ONLY); file_grp.add_argument(args.read_initial_place_file, "--read_initial_place_file") - .help("Writes out the the placement chosen by the initial placement algorithm to the specified file") + .help("Reads the initial placement and continues the rest of the placement process from there.") .metavar("INITIAL_PLACE_FILE") .show_in(argparse::ShowIn::HELP_ONLY); From 4a6043d8714c0de353c22cc4f2e1794e591cf70e Mon Sep 17 00:00:00 2001 From: amin1377 Date: Sat, 27 Jul 2024 18:27:53 -0400 Subject: [PATCH 5/6] apply Soheil's comments --- vpr/src/place/initial_placement.cpp | 7 ++++--- vpr/src/place/place.cpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/vpr/src/place/initial_placement.cpp b/vpr/src/place/initial_placement.cpp index f6e2348d385..f7644a2a808 100644 --- a/vpr/src/place/initial_placement.cpp +++ b/vpr/src/place/initial_placement.cpp @@ -1187,12 +1187,13 @@ void initial_placement(const t_placer_opts& placer_opts, clear_all_grid_locs(); /* Go through cluster blocks to calculate the tightest placement - * floorplan constraint for each constrained block - */ + * floorplan constraint for each constrained block + */ propagate_place_constraints(); /*Mark the blocks that have already been locked to one spot via floorplan constraints - * as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement*/ + * as fixed, so they do not get moved during initial placement or later during the simulated annealing stage of placement + */ mark_fixed_blocks(); // Compute and store compressed floorplanning constraints diff --git a/vpr/src/place/place.cpp b/vpr/src/place/place.cpp index 7259729d4d4..a46a5159650 100644 --- a/vpr/src/place/place.cpp +++ b/vpr/src/place/place.cpp @@ -462,7 +462,7 @@ void try_place(const Netlist<>& net_list, if (!placer_opts.write_initial_place_file.empty()) { print_place(nullptr, nullptr, - (placer_opts.write_initial_place_file).c_str()); + placer_opts.write_initial_place_file.c_str()); } #ifdef ENABLE_ANALYTIC_PLACE From 1d89851d1ce42d965e2c05a6c8525dda6f1c2ead Mon Sep 17 00:00:00 2001 From: amin1377 Date: Sat, 27 Jul 2024 21:39:35 -0400 Subject: [PATCH 6/6] [vpr][place] check constraint location when intial placement file is read --- vpr/src/base/read_place.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vpr/src/base/read_place.cpp b/vpr/src/base/read_place.cpp index f3374e89824..4e52df3b040 100644 --- a/vpr/src/base/read_place.cpp +++ b/vpr/src/base/read_place.cpp @@ -305,6 +305,14 @@ void read_place_body(std::ifstream& placement_file, loc.layer = block_layer; if (seen_blocks[blk_id] == 0) { + if (is_place_file && place_ctx.block_locs[blk_id].is_fixed) { + const auto& contraint_loc = place_ctx.block_locs[blk_id].loc; + if (loc != contraint_loc) { + VPR_THROW(VPR_ERROR_PLACE, + "The new location assigned to cluster #%d is (%d,%d,%d,%d), which is inconsistent with the location specified in the constraint file (%d,%d,%d,%d).", + blk_id, loc.x, loc.y, loc.layer, loc.sub_tile, contraint_loc.x, contraint_loc.y, contraint_loc.layer, contraint_loc.sub_tile); + } + } set_block_location(blk_id, loc); }