Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Prevent extra re-lowerings via "actual targets" #1802

Open
wants to merge 2 commits into
base: master-deprecated
Choose a base branch
from

Conversation

seldridge
Copy link
Member

@seldridge seldridge commented Jul 29, 2020

Add a member to DependencyManager that returns the "actual targets" of
what this DependencyManager solves. This exposes an API to query not
just the targets, but the actual state that results from running the
transform. The actual targets are a superset of the targets that can
prevent unnecessary re-lowering.

Consider the situation of a dependency manager that has one transform
target, foo, and no current state. The flattened transform order that
results pulls in hundreds of other transforms that foo requires.
However, from the perspective of a user looking at the dependency
manager, it's "effect" is only running foo.

This matters when using a DependencyManager to solve a sub-problem. If
the sub-problem is too narrow, e.g., one transform foo, then the
hundreds of other transforms that may be run will be repeatedly run
over and over again because there's no API to query the effect of
solving a (targets, currentState) tuple.

This commit includes a small test that shows this issue.

This commit also removes a spurious addition of ResolveKinds before
ExpandWhensAndCheck.

For the provided test, the old order, without this PR is:

├── firrtlTests.options.ActualTargetsFixture$A
├── firrtlTests.options.ActualTargetsFixture$B
├── firrtlTests.options.ActualTargetsFixture$C
├── firrtl.options.PhaseManager
│   ├── firrtlTests.options.ActualTargetsFixture$A
│   └── firrtlTests.options.ActualTargetsFixture$B
├── firrtlTests.options.ActualTargetsFixture$D
├── firrtl.options.PhaseManager
│   └── firrtlTests.options.ActualTargetsFixture$A
└── firrtlTests.options.ActualTargetsFixture$E

The new order, with this PR is:

├── firrtlTests.options.ActualTargetsFixture$A
├── firrtlTests.options.ActualTargetsFixture$B
├── firrtlTests.options.ActualTargetsFixture$C
├── firrtl.options.PhaseManager
│   ├── firrtlTests.options.ActualTargetsFixture$A
│   └── firrtlTests.options.ActualTargetsFixture$B
├── firrtlTests.options.ActualTargetsFixture$D
└── firrtlTests.options.ActualTargetsFixture$E

The unnecessary re-lowering of A is removed.

This is related to the comment in #1784 (comment).

Note: doing this highlighted two lingering issues of using anonymous transforms in tests. Those are fixed in the first commit of this PR.

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • [n/a] Did you update the FIRRTL spec to include every new feature/behavior?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you state the API impact?
  • Did you specify the code generation impact?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • performance improvement

API Impact

None.

Backend Code Generation Impact

None.

Desired Merge Strategy

  • Squash: The PR will be squashed and merged (choose this if you have no preference.

Release Notes

  • Improved transform scheduling

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels?
  • Did you mark the proper milestone (1.2.x, 1.3.0, 1.4.0) ?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you mark as Please Merge?

@seldridge seldridge requested a review from a team as a code owner July 29, 2020 20:18
Change CInferMDirSpec and ChirrtlMemSpec to not use anonymous
transforms. This causes problems with dependency managers which rely
on a transform being a singleton object or a class that can be
constructed.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Add a member to DependencyManager that returns the "actual targets" of
what this DependencyManager solves. This exposes an API to query not
just the targets, but the actual state that results from running the
transform. The actual targets are a superset of the targets that can
prevent unnecessary re-lowering.

Consider the situation of a dependency manager that has one transform
target, foo, and no current state. The flattened transform order that
results pulls in hundreds of other transforms that foo requires.
However, from the perspective of a user looking at the dependency
manager, it's "effect" is only running foo.

This matters when using a DependencyManager to solve a sub-problem. If
the sub-problem is too narrow, e.g., one transform foo, then the
hundreds of other transforms that may be run will be repeatedly run
over and over again because there's no API to query the effect of
solving a (targets, currentState) tuple.

This commit includes a small test that shows this issue.

This commit also removes a spurious addition of ResolveKinds before
ExpandWhensAndCheck.

Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant