Skip to content

vpr: Add fix_clusters option to allow users to lock down any block to… #1433

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 9 commits into from
Jul 29, 2020

Conversation

sfkhalid
Copy link
Contributor

… an x, y, subtile location

VPR had the option fix_pins to allow users to fix I/O pads to certain locations. The fix_clusters option was added to allow them to fix any block (I/O or otherwise) to an x, y, subtile location. It has the same arguments that fix_pins has - free, random, and user. Using the user argument entails providing a .pads file, just like fix_pins.

Description

Added fix_clusters in the place group options in the read_options.cpp and argparse_test.cpp files.

Related Issue

The related issue is: Add Placement Constraints to VPR #932
#932

How Has This Been Tested?

The fix_clusters option was tested with running vpr with an architecture file that has clbs with a block capacity of greater than one. The vtr_reg_basic and vtr_reg_strong tests were also run.

Types of changes

  • Bug fix (change which fixes an issue)
  • [x ] New feature (change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [x ] My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

@probot-autolabeler probot-autolabeler bot added external_libs lang-cpp C/C++ code tests VPR VPR FPGA Placement & Routing Tool labels Jul 16, 2020
@kmurray
Copy link
Contributor

kmurray commented Jul 18, 2020

Question for @sfkhalid and @vaughnbetz. Is this the same or different from #1189?

@vaughnbetz
Copy link
Contributor

Yes, it's the same. I forgot that one got merged, but Sarah found the functionality works (which makes sense, since Keith added it). She's breaking up the options:
--fix_pins will now only have free(default) and random options.
--fix_clusters will take a file argument, and will specify any placement blocks that should be locked down.
pad_loc_file will be renamed as something new: I suggest constraints.place as a reasonable name since it uses the .place format.
Sarah, inside the code and documentation you should rename pad_loc_file to this new name, and make sure comments and variables names are changed to reflect the new functionality as appropriate.
Sarah is also going to add regtests for the new ability to lock down arbitrary blocks and a regtest to ensure that invalid constraints cause an error.

@vaughnbetz
Copy link
Contributor

Sarah, there appear to be conflicts -- can you check and resolve?
Also, please remove the dead enums we talked about last week, and any other dead code. If fix_pins USER is gone, all mention of it should now be removed from the code.

@sfkhalid
Copy link
Contributor Author

Sarah, there appear to be conflicts -- can you check and resolve?
Also, please remove the dead enums we talked about last week, and any other dead code. If fix_pins USER is gone, all mention of it should now be removed from the code.

Hi Vaughn, when I check this pull request it says that there are no conflicts with the base branch, are you seeing a different message? Also, I'll be sure to commit the code with the USER option completely removed tonight.

@vaughnbetz
Copy link
Contributor

vaughnbetz commented Jul 27, 2020

Looks like it can't be rebased, but it can be directly merged (which would only affect the commit history, making it a bit harder to interpret, which is OK for a straightforward change like this). I see this message:

This branch cannot be rebased due to conflicts
Rebasing the commits of this branch on top of the base branch cannot be performed automatically due to conflicts encountered while reapplying the individual commits from the head branch.

but if I switch to creating a merge commit it is OK.

@probot-autolabeler probot-autolabeler bot added the VTR Flow VTR Design Flow (scripts/benchmarks/architectures) label Jul 29, 2020
@sfkhalid sfkhalid merged commit 22e69b1 into master Jul 29, 2020
@sfkhalid sfkhalid deleted the adding_fix_clusters_option branch July 29, 2020 15:45
Copy link
Contributor

@vaughnbetz vaughnbetz left a comment

Choose a reason for hiding this comment

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

  1. Make changes listed here, do PR.
  2. Also take a look at how the blocks are locked down (in initial_place.cpp). Is it clean? If not, could lock them down when reading the constraints_file. If can be cleaned up, do another PR for that.
  3. It looks like the placement file and constraint file reading could be refactored to have one common routine. Check if that would be cleaner, and if so do a 3rd PR.
  • would have to refactor read_place to call a couple of subfunctions: read_place_header and read_place_body
  • constraints file would also call read_place_body
  • read_place_body should get the error checking from read_constraints_file (stronger checker, assumes user could have typed random stuff)
  • parser from read_place_body looks nicer --> probably build off it.
  • Check that the cluster_netlist.find_block(block_name) is fast (should be using a map or hash table (unordered_map). read_place_constraints is using my hand-written hash table, which isn't as good (doesn't resize for big circuits).
  • Depending on what you did in ODIN II: Instantiating more than one module with dual_port_ram inside fails #2, you might also have to pass in a flag saying whether you are reading as a constraint (set block.locked flag) or a placement file (don't set).
  1. Test using a placement file and a constraint file together. What happens? Current code looks like it will error in odd ways unless the overall control code avoids parsing the constraint file in that case (which would be fine).

@@ -302,6 +303,13 @@ int main(
" or a file specifying the pad locations.")
.default_value("off")
.show_in(argparse::ShowIn::HELP_ONLY);
place_grp.add_argument(args.fix_clusters, "--fix_clusters")
.help("Fixes block locations during placement."
" Can be 'random' for a random initial assignment,"
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to remove random option.

@@ -503,8 +503,10 @@ static void SetupPlacerOpts(const t_options& Options, t_placer_opts* PlacerOpts)

PlacerOpts->place_algorithm = Options.PlaceAlgorithm;

PlacerOpts->constraints_file = Options.constraints_file;
PlacerOpts->pad_loc_file = Options.pad_loc_file;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove pad_loc_file

PlacerOpts->pad_loc_file = Options.pad_loc_file;
PlacerOpts->pad_loc_type = Options.pad_loc_type;
PlacerOpts->block_loc_type = Options.block_loc_type;
Copy link
Contributor

Choose a reason for hiding this comment

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

block_loc_type isn't a great name; not obvious it goes with the constraints file.
But probably better still to simply have a NULL or empty constraints_file name mean no location constraints.

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 the best thing is to delete block_loc_type entirely and use a NULL constraints file name to mean no constraints. Comment it when you do the test for a NULL constraints file (means none specified).

default:
VPR_FATAL_ERROR(VPR_ERROR_UNKNOWN, "Unknown I/O pad location type\n");
}

VTR_LOG("PlacerOpts.block_loc_type: ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Make more user friendly.
should just be PlacerOpts.constraint_file: fname

Copy link
Contributor

Choose a reason for hiding this comment

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

At the same time, put a blank line before the first placer option (or after last packer option). Other groups have a blank line between them; placer and packer should too.

.help(
"Fixes block locations during placement. Valid options:\n"
" * path to a file specifying block locations (.place format with block locations specified).")
.default_value("not_locked")
Copy link
Contributor

Choose a reason for hiding this comment

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

Update this to just have a filename, default is empty string (no constraint file).

@@ -816,8 +821,10 @@ struct t_annealing_sched {
* place_chan_width: The channel width assumed if only one placement is *
* performed. *
* pad_loc_type: Are pins FREE, fixed randomly, or fixed from a file. *
* pad_loc_file: File to read pin locations form if pad_loc_type *
* is USER. *
* block_loc_type: Are blocks fixed from a file. *
Copy link
Contributor

Choose a reason for hiding this comment

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

remove.

* block_loc_type: Are blocks fixed from a file. *
* constraints_file: File to read block locations from if block_loc_type *
* is LOCKED. *
* pad_loc_file: File to read pad locations from if pad_loc_type is USER. *
Copy link
Contributor

Choose a reason for hiding this comment

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

remove pad_loc_file

@@ -870,6 +877,8 @@ struct t_placer_opts {
float place_cost_exp;
int place_chan_width;
enum e_pad_loc_type pad_loc_type;
Copy link
Contributor

Choose a reason for hiding this comment

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

remove block_loc_type

read_user_pad_loc(pad_loc_file);
/*If the user specified block locations using a constraints file, read those locations in here*/
if (block_loc_type == LOCKED) {
read_user_block_loc(constraints_file);
Copy link
Contributor

Choose a reason for hiding this comment

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

Change to just call read_user_block_loc (can have it return if constraints_file is NULL or an empty string). Or could check before calling it with this if ().

@@ -3,7 +3,6 @@

#include "vpr_types.h"

void initial_placement(enum e_pad_loc_type pad_loc_type,
const char* pad_loc_file);
void initial_placement(enum e_pad_loc_type pad_loc_type, enum e_block_loc_type block_loc_type, const char* constraints_file);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove block_loc_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external_libs lang-cpp C/C++ code tests VPR VPR FPGA Placement & Routing Tool VTR Flow VTR Design Flow (scripts/benchmarks/architectures)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants