-
Notifications
You must be signed in to change notification settings - Fork 613
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
Autoclonetype2 #1804
Autoclonetype2 #1804
Conversation
For the record, I think the CI failure is unrelated. The test appears to be failing on master, it might be due to a change in FIRRTL. I'll debug soonish but may not be able to get to it till early next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, minor changes (add newlines to new files)
plugin/src/main/scala-2.12/chisel3/internal/plugin/BundleComponent.scala
Outdated
Show resolved
Hide resolved
plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselComponent.scala
Outdated
Show resolved
Hide resolved
Looks stellar! Great job, this is very exciting and will have enormous impact on runtimes of large designs. Very exciting!!! |
New TODO. I'd still like to backport this to The solution that allows users to still benefit from this without having a binary incompatible change in 3.4.3 is to make this behavior optional via an argument to the plugin, off by default. This Chisel itself will not use the feature in this PR which can be backported, and then will use it on master looking toward 3.5. |
The implication being that users of this chisel can turn the plugin on for their code, and still link against the 3.4.x Chisel compiled with this bit of the plugin turned off, right? |
Exactly, Chisel itself will remain binary compatible, anyone who wants to write a binary compatible library should keep this feature disabled, but anyone who wants the performance benefit in their own code can turn it on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say I understand what all of this is doing, but it look fine.
Otherwise, a high-level description of the transform / plugin behavior, ideally in scaladoc, would be helpful as a guide for reading through the implementation.
plugin/src/main/scala-2.12/chisel3/internal/plugin/BundleComponent.scala
Outdated
Show resolved
Hide resolved
plugin/src/main/scala-2.12/chisel3/internal/plugin/BundleComponent.scala
Outdated
Show resolved
Hide resolved
plugin/src/main/scala-2.12/chisel3/internal/plugin/ChiselComponent.scala
Show resolved
Hide resolved
3c485ed
to
07182f5
Compare
Feedback resolved and new option added so that this feature is opt-in rather than opt-out (for Chisel I intend to merge this shortly and let it backport, and then create a follow on PR for Chisel 3.5 that uses the plugin, perhaps changing the option to opt-out rather than opt-in. |
The compiler plugin obviates the need for using stack traces to determine outer objects in autoclonetype. When the plugin was used to compile a given Bundle, it will no longer collect a stack trace upon construction. This should have massive benefits to elaboration runtime.
07182f5
to
3bea616
Compare
* [plugin] Split ChiselComponent into its own file (cherry picked from commit e80e9a3) * [plugin] Implement autoclonetype in the compiler plugin (cherry picked from commit 1494231) * [plugin] Stop autoclonetype stack traces when using plugin The compiler plugin obviates the need for using stack traces to determine outer objects in autoclonetype. When the plugin was used to compile a given Bundle, it will no longer collect a stack trace upon construction. This should have massive benefits to elaboration runtime. (cherry picked from commit a8d3238) * [plugin] Disable BundleComponent by default, add option to enable (cherry picked from commit 3bea616) * Fix plugin scalacOptions for 2.11 * allowReflectiveAutoCloneType must work outside of Builder context Co-authored-by: Jack Koenig <[email protected]>
Fixes #1803 (by coincidence as far as I can tell)
This change results in a speedup of ~40% and memory reduction 15-20% on large, typical designs. This also reduces memory use by 2-5x in some pathological cases.
Note that the diff is larger than it really is, I split
ChiselPlugin.scala
into 2 files. I did not make any changes to theChiselComponent
(which is really theNamingComponent
). The bulk of my changes are inBundleComponent
. I originally named itAutoCloneTypeComponent
but I realized that it's not too big of an extension on this work to make the plugin also implementval elements
in Bundles as well as solve the "Field problem". I almost did the latter, but it has some potential consequences that make me think it should be done on a major version boundary and I'd like to include this inv3.4.3
. If we also implementval elements
in the plugin, then there is no more runtime reflection necessary in Chisel.Note the 2 new soft links in
no-plugin-tests
, reflective autoclonetype will continue being tested with all of the old tests. Those tests also apply to the new implementation along with some new tests I added.I did add an assertion to reflective autoclonetype with the purpose of checking whether the plugin-generated version is actually in use. The cost of this assertion should be basically free compared to reflection; furthermore, users should use the plugin anyway for a massive performance improvement (to be measured).
Contributor Checklist
docs/src
?Type of Improvement
API Impact
This expands the autoclonetype API to support Bundles with parameters that are not vals. It also can generate cloneTypes for anonymous classes with non-Bundle/Module outer classes.
Backend Code Generation Impact
No impact
Desired Merge Strategy
Release Notes
Generate
cloneType
methods for Bundles in the compiler plugin when provided-P:chiselplugin:useBundlePlugin
as ascalacOption
.This feature is disabled by default because it is a breaking change to implementcloneType
for any non-final Bundle (a child class extending the given Bundle could rely on reflective autoclonetype but will now call the newly implemented one in the superclass instead). Users who intend to publish libraries should not enable the feature until updating to Chisel 3.5. Everyone else should use it beginning in Chisel 3.4.3.Reviewer Checklist (only modified by reviewer)
Please Merge
?