-
Notifications
You must be signed in to change notification settings - Fork 23
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
Memoize first clock type of defn #685
Open
rsetaluri
wants to merge
1
commit into
master
Choose a base branch
from
memoize-get-clk
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we want to memoize the _get_first_clock function right? But I'm not sure if this is really where the best savings will occur, since for one definition, we'll only need to get the first clock once.
I think where it becomes useful is in the wiring of instances. We may have a large number of instances, and we have to check each of their interfaces to find the first clock. If we can memoize the first clock for a definition, then for each instance we can simply lookup the default clock rather than traversing the interface. I suspect most of the savings will come here, since will be repeating the clock lookup logic for instances of the same definition, while definitions only need to lookup their internal clock once
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.
Also,
wireclock
will repeat this logic for each clock type. I think it would be more efficient to wire a set of clock types and handle them all as we're traversing the interface once (rather than traversing the interface each time for each clock type).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.
(a) yes, oops, sorry put the decorator on the wrong function.
(b) with the decorator on the right function, we will only traverse the interface once per (definition, type) pair. If I understand correctly, you're suggesting we simultaneously do the traversal for all the types?
(c) yes, good point about instances. Even if we find we can find the first clock of a defn fast, we still find all the clocks for each instance, and this is repeated even for multiple instances of the same defn. Will try to implement this.
I think the best way to do this is to have an acceleration data structure associated with each defn which is Map[Type, List[String]], where for each type we have the name of all the ports which match that type. We can make this a query and then cache the result per definition. I think it would also be prudent to have an option to stop on the first one if needed.
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.
@leonardt I can try to implement the above.
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.
Actually, I realize (c) is more complicated for nested types. If for example, defn.x[0].y[1] happens to be a clock type, re-targetting that reference to an instance is non-trivial (we basically need to capture all the clock types "by reference"). Will think about the best way to do this.
If we avoid nested types this becomes much easier as all we have to do is save the port name and do
getattr
on instances. But it sounds like nested clocks are definitely important.