Skip to content

Commit

Permalink
Merge pull request #2666 from verilog-to-routing/read_init_place
Browse files Browse the repository at this point in the history
Read Initial Placement
  • Loading branch information
vaughnbetz authored Aug 2, 2024
2 parents b2cf268 + 1d89851 commit 49de5fb
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions vpr/src/base/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,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;
Expand Down
5 changes: 5 additions & 0 deletions vpr/src/base/read_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("Reads the initial placement and continues the rest of the placement process from there.")
.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);
Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/read_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct t_options {
argparse::ArgValue<std::string> write_rr_graph_file;
argparse::ArgValue<std::string> read_rr_graph_file;
argparse::ArgValue<std::string> write_initial_place_file;
argparse::ArgValue<std::string> read_initial_place_file;
argparse::ArgValue<std::string> read_vpr_constraints_file;
argparse::ArgValue<std::string> write_vpr_constraints_file;
argparse::ArgValue<std::string> write_constraints_file;
Expand Down
8 changes: 8 additions & 0 deletions vpr/src/base/read_place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions vpr/src/base/vpr_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 16 additions & 10 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,8 @@ void initial_placement(const t_placer_opts& placer_opts,
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
Expand All @@ -1204,17 +1205,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<ClusterBlockId, t_block_score> block_scores = assign_block_scores();
//Assign scores to blocks and placement macros according to how difficult they are to place
vtr::vector<ClusterBlockId, t_block_score> 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();

Expand Down
2 changes: 1 addition & 1 deletion vpr/src/place/place.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49de5fb

Please sign in to comment.