-
Notifications
You must be signed in to change notification settings - Fork 302
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
[Calyx] Lower Arith CmpFOp to Calyx #7860
base: main
Are you sure you want to change the base?
Conversation
My first guess is this is being inlined because of InlineCombGroups. |
Makes sense, and I think I shouldn’t put them into comb groups in the first place since |
Yes, if you want these to be read in sequential order then they need to be placed in registers. |
1ceae59
to
0db4e8e
Compare
} | ||
|
||
// General case | ||
StringRef opName = cmpf.getOperationName().split(".").second; |
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.
Maybe I should refactor with buildLibraryBinaryPipeOp
, it's tricky though
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 few smaller comments.
|
||
// The combinational logic to apply to the input ports. For example, we should | ||
// apply `AND` logic to the two input ports for predicate `oge`. | ||
enum CombLogic { AND, OR, SPECIAL } logic; |
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.
What is SPECIAL
? It isn't immediatley clear from your documentation.
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.
changed it to noComb
(hopefully the intention that it stands for "no combinational logic" is more obvious)
thanks @cgyurgyik ! I've made changes based on your review |
|
||
// The combinational logic to apply to the input ports. For example, we should | ||
// apply `logicAnd` to the two input ports for predicate `oge`. | ||
enum class CombLogic { logicAnd, logicOr, noComb }; |
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.
Suggestion: It might even be simpler to say None, i.e., CombLogic::None
seems like a less verbose version of CombLogic::noComb
. Usually the NONE case is placed first as well, since it corresponds to the integer 0.
rewriter.create<calyx::AssignOp>(loc, outputLibOp.getRight(), | ||
inputRegs[1].getOut()); | ||
|
||
outputValue = outputLibOp.getOut(); |
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.
should there be a break
here in case a default / another case is added?
@@ -438,3 +438,705 @@ module { | |||
} | |||
} | |||
|
|||
// ----- | |||
|
|||
// Test floating point OEQ |
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.
Let's create a new file float_compare.mlir
or similar containing these tests.
@@ -779,6 +779,28 @@ class BuildCallInstance : public calyx::FuncOpPartialLoweringPattern { | |||
ComponentOp getCallComponent(mlir::func::CallOp callOp) const; |
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.
Nice, looking much better; I've added a few smaller comments. I am curious if you've verified at all the output of this code besides manually checking it, e.g., have you run the emitted code through the native Calyx compiler and checked the outputs via some backend like Icarus or SysVerilog?
This patch tries to lowers
arith::cmpf
to Calyx. Relevant issue: #7821One thing I'm still trying to figure out is that, taking
ult
as an example, I tried to create aCombGroup
to evaluatestd_compareFN.lt || std_compareFN.unordered
.My test case is:
and I
dump
intermediate result afterBuildOpGroups
, it shows:so clearly we can see:
But after the entire execution, it finishes with:
There's no appearance of that combinational group. Any insight why could this happen? @cgyurgyik @andrewb1999 @rachitnigam