-
Notifications
You must be signed in to change notification settings - Fork 895
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
rtlil: Speeds up string decoding by 30% #3940
Conversation
Did you intend to include the change to decode_string here? Or is that going to be a separate PR? |
This change represents about a 2% speed up of Yosys as a whole. Written by @rmlarsen Co-authored-by: Rasmus Larsen <[email protected]> Signed-off-by: Ethan Mahintorabi <[email protected]>
8f6a9f5
to
2235c3f
Compare
Good catch. I added it back. |
bits.reserve(str.size() * 8); | ||
for (int i = str.size() - 1; i >= 0; --i) { | ||
const unsigned char ch = str[i]; | ||
bits.insert(bits.end(), LUT[ch].begin(), LUT[ch].end()); |
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 am bit surprised by this being faster -- would you perhaps have a figure for this change alone?
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.
This in itself is about 20% faster. Decode_string is about 30% faster.
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.
|
||
int i = n_over_8 * 8; | ||
if (i < n) { | ||
fill_byte(i, n); |
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 must say I really dislike the closure here. What about something like:
int cap = GetSize(bits); // where the current byte ends
for (int i = GetSize(bits) / 8 * 8; i >= 0; i -= 8) {
for (int j = i; j < cap; j++) {
...
}
cap = i;
}
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.
Having a named helper function for filling each byte is more readable to me, but I suppose it's a matter of what style you are used to reading. But we can certainly change it.
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.
Please do change it. While at it, please fix the patch to use tabs like in the rest of the file.
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 to consider is splitting the patches: we are ready to merge the decode_string()
change but we are not so sure about the lookup table in the constructor.
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.
@QuantamHD do you want to update / split the PR or should I just file a new one?
We are curious about the timings. Couple of questions: when you say this speeds up Yosys as a whole by 2 %, do you mean some representative ASIC flow you are running on your end? Would you have some typical timings for the |
Hi Martin, Thanks for the comments. Response below.
Yes, the 2% is the reduction in overall time of the synthesis flow for a representative circuit from a Google hardware block that we are running through Yosys. I can provide you with a flame graph for example, since that probably gives more context, or a wider slice of the Tree view. |
Hello Rasmus, Yes, anything you could provide to inform our discussion would be helpful. |
@povik Will do. Notice that @QuantamHD is OOO until tomorrow. I'd like to coordinate with him on how to proceed in terms of splitting, so give us a few days. Thanks. |
We will probably next look at this on Monday 14:00 UTC during the weekly development call (which is btw open to public and you are more than welcome to join if interested). |
Ah, good to know. Thanks! Would be nice to join the call if I can at some point. |
Link here: https://meet.jit.si/yosyshq-slack-devel-discuss It's scheduled to be an hour long, occurs every week. |
@rmlarsen Should we close this then? |
@QuantamHD sure. We can upstream the |
This change represents about a 2% speed up of Yosys as a whole.
Written by @rmlarsen