fix CRITICAL overflow and underflow issue in PE.scala #315
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.
I have found that MacUnit implemented on pull #265 causes overflows and underflows inside the mesh when the supported dataflow of gemmini is
dataflow=Dataflow.WS
.This issue does not occur when the supported dataflow is
dataflow=Dataflow.BOTH
.The cause is as follows:
The bitwidth of
MacUnit.io.in_c
is set tocType
when thedataflow=Dataflow.WS
,where
val cType = if (df == Dataflow.WS) inputType else accType
.MacUnit.io.in_c
is the "Partial Sum (from PE above)" of the PE. This net needs width equal to beaccType
of gemmini,in order to prevent overflows and underflows of partial sums.
So I have changed the width of
MacUnit.io.in_c
to be same asaccType
.And another interesting observation was that, built-in baremetal examples of matmul usually had no issues with the faulty code. This was because the random inputs and weight of the baremetal codes had too small absolute values to cause any overflows or underflows.
I suggest improving the random number generation of the baremetal codes a bit.