question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Clone Module" API Idea and Request for Comment

See original GitHub issue

As designs grow larger and larger, we are starting to hit fundamental performance problems in both Firrtl and Chisel. There are many techniques to deal with this, and one useful one I think we should consider is allowing users to explicitly “clone” Modules. This would actually partially address both #472 and https://github.com/ucb-bar/firrtl/issues/538.

Cloning would essentially create another Firrtl instance of an already elaborated Module. There are some subtle issues to think about with annotations (Module.component annotations would probably be fine but hierarchical ones would need duplication).

I propose something like:

val inst0 = Module(new MyModule)
val inst1 = inst0.cloneModule
// or
val inst2 = Module.cloneInst(inst0)
// or 
val inst3 = Module.duplicate(inst0)

This does present some serious problems for systems like rocket-chips’s LazyModule that utilize their own data structures to emit information about the configuration and the like. However, as a strictly opt-in feature such libraries could better leverage annotations or provide their own APIs that call ours to take advantage.

Thoughts? Questions? Concerns?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:23 (22 by maintainers)

github_iconTop GitHub Comments

1reaction
jchang0commented, Jun 1, 2017

An expansion to this which is related that might use the same underlying code in the future is incremental chisel compile. As the design gets larger, we might need incremental compile capability

I imagine that it might be related since we have to guarantee that the module we generated before is exactly the same as the module we are compiling now to be able to skip the compilation step. Granted that some firrtl optimization can no longer work across boundaries, it might be something that the user have to specify a particular module is subject to incremental compile and known optimization might not be applied.

1reaction
chickcommented, May 25, 2017

Do you have some estimate of the gain here? Your example was of an unparameterized Module, is that relevant or just a simpler example. It seems to me that requiring users to do this is not that desirable, it seems a bit hard to explain, users would likely not employ the technique at first and then when they hit the wall would have to go back and fix a bunch of existing code. Could Module.apply could be some soft of factory that (optionally) recognized creating of previous modules and did this under the hood.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloning Content | ArcGIS API for Python
Leveraging the Python API to clone content from one Web GIS to another can be thought of as "propagating content that appears to...
Read more >
Cloning a project from git returns the project though modules ...
Use Maven or Gradle for the project, this way IntelliJ IDEA will import the project and configure all the modules and their dependencies ......
Read more >
Discuss: Expose Structured Clone on v8 Module #34355
Using the V8 serialization API, Node.js apps can run a structured clone like so: const v8 = require('v8'); const structuredClone = (o) ...
Read more >
Clone a Project from GitHub | The IntelliJ IDEA Blog
In this blog, we're going to look at how to create an IntelliJ IDEA project from existing code in a GitHub repository.
Read more >
Best practices for writing code comments - Stack Overflow Blog
Rule 1: Comments should not duplicate the code. ... It's a good idea to comment code that someone else might consider unneeded or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found