Skip to content

Add typed application options, generated from VPR, with set_app_option and report_app_option - #2840

Open
ganeshgore wants to merge 4 commits into
gg_openfpga_sessionfrom
gg_app_options
Open

ganeshgore wants to merge 4 commits into
gg_openfpga_sessionfrom
gg_app_options

Conversation

@ganeshgore

@ganeshgore ganeshgore commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

The engines of the flow (clustering, placement, routing, analysis) take many parameters. This adds a table of typed options that the OpenFpgaSession owns, that can be set between the stages, and that can be inspected. The options of VPR are generated from VPR's own sources, so their names, types, help, accepted values and defaults follow the version of VPR in use. Setting an option makes the stage it tunes out of date. Nothing in the flow reads the options yet, so behavior is unchanged.

Changes

  • AppOptionValue is a string, int, float, bool or selection, with a help message. A selection lists the values it accepts and the VPR enumeration each stands for.

  • AppOptions is a flat map from group.option (for example place.seed) to the value, with the default of every option. It can be copied, listed and reset.

    • The values are read from text according to the type: whole numbers for int, finite numbers for float, true/false/on/off/yes/no/1/0 for bool, and only the listed values for a selection.
    • A value that is not valid is refused with a message naming the option, its type and the value (and the choices for a selection). The option keeps its value.
  • The options of VPR are generated by openfpga_flow/scripts/generate_vpr_option_mapping.py from read_options.h and read_options.cpp:

    • 222 options in the groups filename, general, atom, cluster, aplace, place, tplace, router, trouter, analysis, power and crr. The groups are VPR's own argument groups.
    • For each: its name, type, help text, flag, the values a selection accepts (read from VPR's parsers), and a function reading its value from t_options.
    • Defaults are read from VPR when the options are created, so they are always VPR's. Files that VPR names after the circuit stay empty.
    • 49 fields of t_options are left out, each with a recorded reason: stage switches, graphics, NoC, run control, verbosity, formats, and options VPR infers. The script fails when a field has neither an option nor a reason.
    • Two options are OpenFPGA's own and written by hand: build_fabric.reorder_incoming_edges and build_fabric.sort_gsb_chan_node_in_edges.
  • The options reach VPR as a command line for read_options(), as a user would type it (vpr_args_from_app_options(), read_vpr_options()). read_options() infers defaults from the options that were specified, so this gives the setup VPR itself would build. Only options that differ from their default are given; the architecture and circuit are the positional arguments.

  • Two new commands:

    • set_app_option --name <option> --value <value>
    • report_app_option [--name <option>]

    An invalid set_app_option is a fatal error, so a mistyped option in a script does not go unnoticed. Both commands are documented in basic_commands.rst.

  • OpenFpgaSession owns the options, and they are kept when the session is reset.

  • Every option belongs to a stage of the flow, taken from its group (filename, general, atom: device; cluster: packing; aplace, place, tplace: placement; crr, router, trouter: routing; analysis, power: analysis; build_fabric: repacking). A few filename options and the appack_* options have the stage of the file or of the packer they concern, and the earlier stage is taken when in doubt.

    • Changing the value of an option, or resetting it, drops the results of its stage and of the stages that depend on it. The earlier stages and the other branch of the stage tree are kept, so a change to place.seed after routing keeps the packing and forces placement and routing to run again, and a change to analysis.* does not touch the repacking.
    • Setting the value an option already has changes nothing.
    • The session sets and resets the options (OpenFpgaSession::set_app_option, reset_app_option, reset_app_options), so nothing can change an option without invalidating the stages.
  • libopenfpgashell is untouched and does not depend on VPR.

Testing

  • ctest runs three tests for this:
    • test_app_options (13 cases): the table, parsing by type, refused values, error messages, reset, copies, ownership by the session.
    • test_vpr_app_options (9 cases):
      • every field of t_options is accounted for;
      • 198 options are tried against VPR, each in its own process since VPR exits on a rejected command line, and each reaches the right field with its value;
      • defaults are VPR's;
      • the command-line rules hold;
      • the setup VPR prints for an architecture and a circuit is identical from the options and from a hand-written command line.
    • vpr_option_table_up_to_date fails when the generated file is out of date.
  • test_app_option_stages (10 cases): every option has a stage, the stage of each group and of the exceptions, place.seed after routing keeps the packing and drops placement and what follows, routing options drop both branches, analysis options keep the repacking, build_fabric options keep the analysis, options of stages not reached change nothing, and an unchanged or refused value keeps the stages. Planted bugs caught: no invalidation, invalidation on an unchanged value, a wrong stage for a group, and dropping everything instead of the dependent stages.
  • 33 pytest tests drive the commands from Python: set then read back for every type, the exact error messages, reporting all options, and options belonging to one shell.
  • I checked the tests can fail by planting bugs, and each was caught: typed values not parsed, no selection validation, a wrong flag, a forgotten field, booleans sent as true instead of on, defaults sent as well, and a derived file option no longer left empty.
  • The full build is clean with no warnings in the new files. clang-format and black are clean.

Notes

  • After changing the VTR version, run python3 openfpga_flow/scripts/generate_vpr_option_mapping.py and review the result. The generated file is openfpga/src/base/vpr_option_table.cpp.
  • Values are not range-checked beyond their type.
  • The new tests check the bookkeeping of the stages. Whether the results change as expected when place.seed or router.max_router_iterations change can only be tested once the stage commands exist.

@ganeshgore
ganeshgore added this pull request to stack #2834 October 27, 2026 05:07
@ganeshgore ganeshgore changed the title Add typed application options with set_app_option and report_app_option Add typed application options, generated from VPR, with set_app_option and report_app_option Oct 27, 2026
@github-actions github-actions Bot added the tests label Nov 10, 2026
@ganeshgore
ganeshgore removed this pull request from stack #2834 November 20, 2026 05:30
@ganeshgore
ganeshgore added this pull request to stack #2890 November 20, 2026 05:30
@ganeshgore
ganeshgore force-pushed the gg_app_options branch 2 times, most recently from 4e3133d to fb55321 Compare November 27, 2026 04:45
The engines of the flow (clustering, placement, routing, analysis) take
many parameters. Keep them in a table of typed options that is owned by the
OpenFpgaSession, can be set between the stages, and can be inspected.

- AppOptionValue: a string, int, float, bool or selection, with a help
  message. A selection lists the values it accepts and the enumeration they
  stand for
- AppOptions: a flat map from group.option (e.g., place.seed) to the value,
  with the default of every option. It can be copied and listed, and an
  option can be reset
- The values are read from text according to the type, and a value that is
  not valid is refused with a message naming the option and the type, and
  the choices for a selection. The option keeps its value
- 206 options in 11 groups, taken from the VPR options of the version
  vendored here. Selections carry the VPR enumerations
- set_app_option --name <option> --value <value> and
  report_app_option [--name <option>]. An invalid set is a fatal error
- The options are kept when the session is reset
- Add unit tests (ctest) and tests of the commands from Python
The hand-written table of options did not follow VPR: against the vendored
VTR, 33 of its defaults were not the ones of VPR, and some selections used
values that VPR rejects (e.g., gnd for the unconnected outputs of the
post-synthesis netlist, or spellings of the analytical placement solvers).

VPR reads its options with read_options(), which also infers defaults from
the options that were specified. Give the application options to
read_options() as a command line, as a user would type them, so that the
setup is the one VPR builds. Only the options that differ from their
default are given.

- Add openfpga_flow/scripts/generate_vpr_option_mapping.py. It reads
  read_options.h and read_options.cpp, and writes vpr_option_table.cpp: for
  each option its group, name, type, help, flag, the values a selection
  accepts (from the parsers of VPR) and a function reading its value from
  t_options. It fails when a field of t_options has neither an option nor a
  reason to be left out
- The defaults are read from VPR when the options are created. Only the
  options of OpenFPGA (build_fabric.*) are written by hand
- Add vpr_args_from_app_options() and read_vpr_options()
- The architecture and the circuit are the positional arguments of VPR.
  The files VPR names after the circuit stay empty
- Remove the hand-written selection maps and the static table
- Add unit tests: every field of t_options is accounted for, every option
  reaches the right field of VPR with its value, the defaults are the ones
  of VPR, the command line follows the rules of VPR, and the setup VPR shows
  for an architecture and a circuit is the same from the options and from a
  command line. Add a ctest that the generated file is up to date
Every application option belongs to a stage of the flow, taken from its
group, with a few exceptions among the filename options. Setting an option to
a new value, or resetting it, drops the results of that stage and of the
stages that depend on it, and keeps the earlier ones and the other branch of
the stage tree. Setting the value an option already has changes nothing.

The session sets and resets the options, so that nothing can change one
without invalidating the stages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant