celledges: support shift ops#3972
Conversation
povik
left a comment
There was a problem hiding this comment.
Wait, I am not sure this handles Y_WIDTH != WIDTH, let me double-check.
|
Yeah, looks like the case of |
|
Oh right, should that be |
|
I don't think so since then you don't register the dependencies of the higher bits on Y. |
|
Had to take a moment and draw my diagrams again, but I think this should do it. |
|
I think we have yet to take into account the sign-extension of the input, e.g. with a |
|
Right, that now is a problem when previously I thought it was covered since the msb of A could already end up in any (lower) position. Thanks for paying attention to that! |
|
Looking at how tricky this is to get right I started writing a pass to verify the celledges data with a SAT solver. Let's see, let me try it out on the code from the PR. |
|
Isn't that what test_cells is supposed to do with this? (I ran it quickly on $sshr after the last commit before going off to dinner, was going to look into what it actually does later) |
kernel/celledges.cc
Outdated
| db->add_edge(cell, ID::B, k, ID::Y, i, -1); | ||
|
|
||
| if (cell->type.in(ID($shl), ID($sshl))) { | ||
| for (int k = min(i, a_width); k >= 0; k--) |
I don't think so. Or rather, I am letting |
|
It found a failing test case on Looking at the the signed extension of |
Ah, you are right, that's exactly what |
|
So |
5b347f6 to
0f4eff9
Compare
0f4eff9 to
6c562c7
Compare
|
At least one unhandled case I see in the code now is the distinction between signed and unsigned |
|
Oh yeah I haven't started |
|
OK, will focus on shr first then |
|
With the latest commit |
OK, I understood the definition of |
This passes `test_cell -edges` on all the types of shift cells.
| @@ -0,0 +1 @@ | |||
| test_cell -s 1705659041 -n 100 -edges $shift $shiftx $shl $shr $sshl $sshr | |||
There was a problem hiding this comment.
I wonder, should we leave the seed unspecified in order to get better test coverage? It still prints the chosen seed in the log so we can reproduce if necessary.
There was a problem hiding this comment.
I think the potential for confusion when a CI job starts failing for reasons unrelated to the underlying code change is much worse than the benefit of the extra coverage we would get. FWIW I let the test_cell command complete with a much larger N when I was working on this.
There was a problem hiding this comment.
But the alternative to failing on a later CI run from a previous breaking change is to never fail, which means we don't realize that it's broken at all. I would quibble with calling that a "much better" outcome!
There was a problem hiding this comment.
I guess where I see the value is that we can discount "this is broken due to an unlucky seed" when reasoning about CI failures, which I weight against the chance that this will help us find a bug which would otherwise stay hidden, which I think is low. (Anyone touching the shift edges code should be asked to do a long test_cell run anyway.)
If someone down the line touches e.g. the SAT code and this prompts a failure in this test, we will know it's the SAT changes for sure, and that's valuable. At least that's how I think about this.
There was a problem hiding this comment.
I can see your point but I don't think it would be that difficult to trace which part is the problem. If the test fails I think the first debugging step would be to run the same test with the code before the change, at which point it would become obvious that the failure existed earlier. I guess that does require knowing that this test uses random generation and that you need to use the same seed, which you might miss if you don't read the log backscroll far enough. (Maybe for convenience test_cell should print the seed again as the last line if a test fails?)
There was a problem hiding this comment.
I'd prefer CI runs triggered by PRs to be deterministic, but I don't see an issue with using randomized seeds for the daily CI runs.
There was a problem hiding this comment.
I don't think it's worth adding lines in the CI configurations for this one test, let's just keep it deterministic then.
There was a problem hiding this comment.
I would quibble with calling that a "much better" outcome!
I strongly disagree with any argument that describes nondeterministic CI a non-worse outcome. If your CI is nondeterministic, it reduces faith in that the CI works at all. Eventually you create a culture of simply restarting the CI run if something fails because it's known to be flaky.
It's OK to have a separate job that is clearly and expressly marked as nondeterministic (this is basically a simple fuzzer) but merging must not be gated on it unless there's strong explicit consensus that this is a good idea.
There was a problem hiding this comment.
But by that argument, it would be "better" if we were never running any synth pass in CI at all, since abc is currently nondeterministically breaking CI.
There was a problem hiding this comment.
Yep, I think not running nondeterministic tests at all is better than nondeterministically breaking CI. If we (YosysHQ) took testing seriously we would have made ABC deterministic, which I have offered workable solutions for.
I will note that I've also introduced the -noabc flow, which could be an interim alternative to using ABC while it's still nondeterministic.
|
LGTM |
No description provided.