Skip to content

legalizer frontend #2615

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 8 commits into from
Jun 19, 2024
Merged

legalizer frontend #2615

merged 8 commits into from
Jun 19, 2024

Conversation

KA7E
Copy link
Contributor

@KA7E KA7E commented Jun 13, 2024

Frontend modifications to incorporate legalizer.

Description

vpr_api.cpp:

  1. Added code to invoke the legalizer in vpr_pack_flow as follows:
    if doPacking=STAGE_LOAD and packer_opts.load_flat_placement=true, this code:
    a. builds the device grid per a specified fixed device layout
    b. calls load_flat_place (impl coming soon), which will:
    - load and legalize the input flat placement file
    - print a clustered netlist
    - print a fixed clusters (partial .place) file
    c. clears the device grid
    d. if placement will run next, specifies the fixed clusters file as a constraints file.
    e. resumes normal load packing behavior (load .net file, do various checks)
  2. Added a function call to print a flat placement file after VPR placement

SetupGrid.h:
Added default arguments to create_device_grid so that it can be called with a fixed device layout without other args (that are only used when auto-sizing).

read_options.h/cpp:
Added the following command line inputs:
--legalize, enables the legalizer
--flat_place_file , legalizer input file
--write_fix_clusters (default: fix_clusters.out), for legalizer placed clusters output
--write_flat_place (default: flat_place.out), for post-placement flat placement output

SetupVPR.cpp:
Added the following fields to the FileNameOpts data structure:

  • FlatPlaceFile
  • write_constraints_file
  • write_flat_place_file
    Added a do_legalize option, which sets doPacking to STAGE_LOAD and sets a flag (packer_opts.load_flat_placement) instructing the packer to load from a flat placement file.

CheckSetup.cpp:

  1. Added a check that errors out if a fixed device layout is not specified for legalization.
  2. Added a check that errors out if an input constraints file is specified (using --fix_clusters ) when running legalization, since the legalizer will provide cluster placement info.

read_place.h/cpp:
Added an optional boolean input to print_place which defaults to true (in which case the function's behavior does not change). If false, the header is not printed, unplaced blocks (loc.x = -1) are skipped, and the net_file and net_id parameters are unused and can be set to nullptr. This is useful if the output will be used as a constraints (fix clusters) file.

added load_flat_place.h/cpp:
Function to print a flat placement file.
Function to load flat placement (impl coming soon).

Related Issue

Motivation and Context

Incorporates the legalizer.

How Has This Been Tested?

Verified that, if legalizer option is not enabled, vpr runs as usual with no QoR change.
The legalization capability has been tested on all Titan23 benchmarks.

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:

  • 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

@github-actions github-actions bot added VPR VPR FPGA Placement & Routing Tool lang-cpp C/C++ code labels Jun 13, 2024
@KA7E KA7E requested a review from vaughnbetz June 13, 2024 22:40
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.

Some suggested changes.
One more thing: we'll need a documentation topic for the new file format and command line options. The high level documentation can be in the new file format description (that matches what we do for other things, like floorplanning constraints).

Between the documentation and some high level commenting, the overall flow & use case of a flat placement should be clear (right now the big picture isn't documented). The separate documentation can be done in a separate PR if more convenient.

We should also define if a flat placement needs to include a placement for every atom or if only some is OK (in that high level documentation).

@KA7E
Copy link
Contributor Author

KA7E commented Jun 18, 2024

@AlexandreSinger can you help me figure out why these keep failing?

@vaughnbetz
Copy link
Contributor

vaughnbetz commented Jun 18, 2024

It looks like memory corruption. I looked at one of the strong regtests, and there are a huge number of failures due to vpr not completing. You can download the raw logs by clicking on the gear icon after clicking on a test:

2024-06-18T12:15:00.0635639Z �[32;1m12:15:00�[0m | log file : /root/vtr-verilog-to-routing/vtr-verilog-to-routing/vtr_flow/tasks/regression_tests/vtr_reg_nightly_test7/titan_other_run_flat/run001/stratixiv_arch.timing.xml/sudoku_check_stratixiv_arch_timing.blif/common/vpr.out

You can see the vpr output by selecting the download log archive from the same gear icon, double clicking on a regression test and opening the big text.txt output file. That shows there is a segmentation fault at the end of placement (signal 11 is a seg fault), e.g.:

2024-06-18T12:05:27.4656365Z <Placement perturbation distribution by block and move type:
2024-06-18T12:05:27.4657772Z <------------------ ----------------- ---------------- ---------------- --------------- ------------
2024-06-18T12:05:27.4658857Z < Block Type Move Type (%) of Total Accepted(%) Rejected(%) Aborted(%)
2024-06-18T12:05:27.4660073Z <------------------ ----------------- ---------------- ---------------- --------------- ------------
2024-06-18T12:05:27.4661159Z <io Uniform 11.67 28.57 71.43 0.00
2024-06-18T12:05:27.4662149Z < Median 16.67 10.00 80.00 10.00
2024-06-18T12:05:27.4662998Z < Centroid 8.33 20.00 80.00 0.00
2024-06-18T12:05:27.4663864Z < W. Centroid 40.00 41.67 58.33 0.00
2024-06-18T12:05:27.4664778Z < W. Median 1.67 0.00 100.00 0.00
2024-06-18T12:05:27.4665714Z < Crit. Uniform 3.33 0.00 100.00 0.00
2024-06-18T12:05:27.4666674Z < Feasible Region 1.67 0.00 100.00 0.00
2024-06-18T12:05:27.4667495Z <
2024-06-18T12:05:27.4668064Z <clb Uniform 5.00 0.00 0.00 100.00
2024-06-18T12:05:27.4669003Z < Median 3.33 0.00 0.00 100.00
2024-06-18T12:05:27.4670857Z < W. Centroid 8.33 0.00 0.00 100.00
2024-06-18T12:05:27.4671675Z <
2024-06-18T12:05:27.4672021Z <
2024-06-18T12:05:27.4674310Z <Placement Quench timing analysis took 2.0208e-05 seconds (1.5038e-05 STA, 5.17e-06 slack) (1 full updates: 1 setup, 0 hold, 0 combined).
2024-06-18T12:05:27.4676676Z <Placement Total timing analysis took 0.0011949 seconds (0.00114186 STA, 5.3039e-05 slack) (Command terminated by signal 11
2024-06-18T12:05:27.4680085Z < Command being timed: "/home/runner/work/vtr-verilog-to-routing/vtr-verilog-to-routing/vpr/vpr k6_N10_mem32K_40nm.xml multiclock --circuit_file multiclock.pre-vpr.blif --net_file ../../../../multiclock.net --verify_file_digests

I suggest running a circuit locally and bringing it up in the debugger to see the call stack, and/or you could run the sanitized build or valgrind.

@KA7E
Copy link
Contributor Author

KA7E commented Jun 19, 2024

Silly me, forgot to delete the old (unconditional) call to print_flat_placement when I moved it inside a function and added a condition. @vaughnbetz can you take a look once CI has finished?

@vaughnbetz
Copy link
Contributor

Looks good; thanks.

@vaughnbetz vaughnbetz merged commit 95b8fee into master Jun 19, 2024
53 checks passed
@vaughnbetz vaughnbetz deleted the legalizer_frontend branch June 19, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-cpp C/C++ code VPR VPR FPGA Placement & Routing Tool
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants