-
Notifications
You must be signed in to change notification settings - Fork 615
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
Optimize truth table merge #3993
Conversation
This allows it to test package private methods.
Most TruthTables have a default of all dont care. We can optimize this common case by doing actual work in TruthTable.split and TruthTable.merge.
ff87326
to
bb32df4
Compare
@@ -437,6 +437,18 @@ sealed class BitPat(val value: BigInt, val mask: BigInt, val width: Int) | |||
} | |||
} | |||
|
|||
/** Are any bits of this BitPat `?` */ | |||
private[chisel3] def hasDontCares: Boolean = width > 0 && mask != ((BigInt(1) << width) - 1) |
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.
width of bp cannot be 0. Maybe assert out?
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'm future proofing this such that if we do allow it, these should be correct for it (see stubs in tests).
I have added benchmarking results, not extremely rigorous but in practice this is a huge improvement. |
the reason of splitting is because cannot support the existence of both |
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. Let’s make common case fast!
Since split is only designed for long decode output with 0 and 1
* Move BitPatSpec from package chiselTests to package chisel3 This allows it to test package private methods. (cherry picked from commit 09d6fa7) * Add package private all* methods to BitPat (cherry picked from commit e9a2c6d) * Optimize TruthTable.split and .merge to do nothing in common case Most TruthTables have a default of all dont care. We can optimize this common case by doing actual work in TruthTable.split and TruthTable.merge. (cherry picked from commit bb32df4) --------- Co-authored-by: Jack Koenig <[email protected]>
I'm collecting numbers, but it should be pretty obvious that not essentially doing a deep copy of every TruthTable both before and after running espresso minimization in the common case where the default value is uniform (i.e. all ones, all zeros, or, most commonly, all dont care) will speed things up.
To implement this, I also added some useful methods to BitPat that you can see the tests for.
Doing split and merge on the
TruthTable
fromTruthTableSpec
:Before this change:
After this change:
Also from a large real design, I measured it was spending 2 minutes in the little filter function in split:
chisel/src/main/scala/chisel3/util/experimental/decode/TruthTable.scala
Line 145 in d584dd7
With this change, it now spends 0.3ms in that function which just shows how much unnecessary splitting we were doing 🙃.
Contributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.