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

[Autotuner] - Tunable variables check #2452

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

luarss
Copy link
Contributor

@luarss luarss commented Oct 12, 2024

PR Goals

In future PRS

  • Add yamllint + CI
  • Add tests + CI

Copy link
Collaborator

@oharboe oharboe left a comment

Choose a reason for hiding this comment

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

Lots of good stuff, some things to be addressed, break into several PRs, one for each concern(which will simplify reviews allow PRs to flow into master more smoothly)

@@ -100,6 +100,7 @@ configuration file.
| <a name="GPL_TIMING_DRIVEN"></a>GPL_TIMING_DRIVEN| Specifies whether the placer should use timing driven placement.| |
| <a name="GUI_TIMING"></a>GUI_TIMING| Load timing information when opening GUI. For large designs, this can be quite time consuming. Useful to disable when investigating non-timing aspects like floorplan, placement, routing, etc.| |
| <a name="HOLD_SLACK_MARGIN"></a>HOLD_SLACK_MARGIN| Specifies a time margin for the slack when fixing hold violations. This option allows you to overfix.| |
| <a name="IO_CONSTRAINTS"></a>IO_CONSTRAINTS| File path to the IO constraints .tcl file.| |
Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose not updating FlowVariables.md in pull requests that modify generate-variables-docs.py because it is likely to cause conflicts with other PRs in flight.

# information about the variables from variables.yaml.
"""
This script injects an autogenerated section in FlowVariables.md with
information about the variables from variables.yaml.
Copy link
Collaborator

Choose a reason for hiding this comment

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

break out update to generate-variables-docs.py to separate PR, it has nothing to do with AutoTuner.

]
def load_yaml(yaml_path: str) -> dict:
if not os.path.exists(yaml_path):
raise FileNotFoundError(f"File {yaml_path} not found")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting: why are you checking here instead of letting open() propagate this exception? What is the difference?

Seems like this code should be removed, or at least it is very surprising and I have never seen it.

If there is a reason to keep it, it deserves a comment.

Copy link
Contributor Author

@luarss luarss Oct 13, 2024

Choose a reason for hiding this comment

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

I usually try to write this to catch the exact exception triggering the open() error. Makes the code slightly verbose but easier to debug. 99% of the time open(... , "r") do fail with FileNotFoundError, but there might be other exceptions out there.

Also yaml.safe_load() might fail too (e.g. invalid yaml)

Copy link
Collaborator

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 leave file not found to open(), it is what all other python code i have seen does: minimize surprises and questions in the code.

there is no evidence of specific unique circumstances here.

flow/util/utils.mk Outdated Show resolved Hide resolved
flow/scripts/tunable.py Outdated Show resolved Hide resolved
flow/scripts/variables.yaml Outdated Show resolved Hide resolved
flow/scripts/variables.yaml Outdated Show resolved Hide resolved
flow/scripts/variables.yaml Outdated Show resolved Hide resolved
tools/AutoTuner/src/autotuner/distributed.py Outdated Show resolved Hide resolved
flow/scripts/variables.yaml Outdated Show resolved Hide resolved
@luarss luarss changed the title WIP [Autotuner] - Tunable variables check [Autotuner] - Tunable variables check Oct 13, 2024
@luarss luarss marked this pull request as ready for review October 13, 2024 09:54
Copy link
Collaborator

@oharboe oharboe left a comment

Choose a reason for hiding this comment

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

some comments during my ambling walk around ORFS...

variables.add(variable.strip().upper())
# Read from variables.yaml and get variables with tunable = 1
os.chdir(vars_path)
with open("variables.yaml") as file:
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't use os.chdir(), use full paths instead.

tools/AutoTuner/src/autotuner/distributed.py Outdated Show resolved Hide resolved
tools/AutoTuner/src/autotuner/distributed.py Outdated Show resolved Hide resolved
docs/user/FlowVariables.md Show resolved Hide resolved
@luarss luarss marked this pull request as draft October 16, 2024 09:30
@luarss luarss marked this pull request as ready for review October 17, 2024 00:35
Copy link
Collaborator

@oharboe oharboe left a comment

Choose a reason for hiding this comment

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

nits

tools/AutoTuner/src/autotuner/distributed.py Outdated Show resolved Hide resolved
# if key not in flow_variables:
# print(f"[ERROR TUN-0017] Variable {key} is not tunable.")
# sys.exit(1)
if flow_variables.get(key, 0) == 0:
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a set and "key in flow_variables", easier to read

@luarss luarss marked this pull request as draft November 11, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autotuner: Make flow variable detection more robust
2 participants