Skip to content
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

Read Initial Placement #2666

Merged
merged 6 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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/SetupVPR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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
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
29 changes: 17 additions & 12 deletions vpr/src/place/initial_placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
amin1377 marked this conversation as resolved.
Show resolved Hide resolved
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*/
amin1377 marked this conversation as resolved.
Show resolved Hide resolved
mark_fixed_blocks();

// Compute and store compressed floorplanning constraints
Expand All @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if both constraint and initial placement files are specified?

I think read_constraints() initializes the location of some blocks and mark them as fixed. The location in the initial placement would override the location in the constraint file. We probably need to handle this case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to print something to show that the initial placement is read from a file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The locations in the initial placement file will override the assigned locations in the constraint file. However, at the end of the initial placement, we call a function to check the legality of the placement, and any issues can be caught there.

Regarding printing that the initial placement is read from a file, the read_place function prints a message indicating that the placement is read from a file, along with the file name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to check_initial_placement_legality() or another function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant this function. I thought it would check whether the location of the fixed blocks matched the one specified in the constraint file, but upon reviewing the implementation, I realized that's not the case.

To avoid slowing down set_block_location, which is on the critical path of the placement code, I added the check when the placement file is read in the read_place.cpp file.

} 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());
soheilshahrouz marked this conversation as resolved.
Show resolved Hide resolved
}

#ifdef ENABLE_ANALYTIC_PLACE
Expand Down