Skip to content
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] IfOp's group has to be a CombGroupOp? #7682

Open
jiahanxie353 opened this issue Oct 8, 2024 · 3 comments
Open

[Calyx] IfOp's group has to be a CombGroupOp? #7682

jiahanxie353 opened this issue Oct 8, 2024 · 3 comments
Labels
Calyx The Calyx dialect

Comments

@jiahanxie353
Copy link
Contributor

Does IfOp's Group has to be a CombGroupOp, as required here?

What if we have some examples like:

  func.func @main(%arg0 : i32) {
    %two = arith.constant 2: i32
    %rem = arith.remui %arg0, %two : i32
    %cond0 = arith.cmpi eq, %arg0, %rem : i32

    scf.if %cond0 {
      some operations
    } else {
      some operations
    }

where %cond0 involves comparing the out of remui_pipe_op, which is not combinational?

What was the original design criteria? I believe @mortbopet is the original author. Also tagging @rachitnigam @cgyurgyik

@cgyurgyik
Copy link
Member

This was probably a requirement that existed when this was initially implemented: https://docs.calyxir.org/lang/ref.html#if

@jiahanxie353
Copy link
Contributor Author

This was probably a requirement that existed when this was initially implemented: https://docs.calyxir.org/lang/ref.html#if

Ahh indeed, thanks for pointing that out!

Is it true that if statements with with groups is still an ongoing discussion: calyxir/calyx#1699?

Semantically, I believe my example makes sense, where one of the lhs/rhs of the comparison is a result of some operation, which can be either a combinational circuit or sequential ones (like multi_pipe_op/divi_pipe_op/remui_pipe_op, since the upstream tools should be unaware if an operation is implemented combinationally or sequentially in hardware?).

As separate question, is there any workaround over this Well-formedness check, so that we can still have if %cond with comb_group, and that comb_group somehow compares remui_pipe_op.out with %arg0 combinationally?

@jiahanxie353 jiahanxie353 added the Calyx The Calyx dialect label Oct 8, 2024
@rachitnigam
Copy link
Contributor

No, for non-combinational computations, you need to manually perform the computation in a group, store the value in a register, and then use the value of the register to perform the computation. For example:

compute_cond; // computes rem and store in reg
if reg.out { ... } else { ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Calyx The Calyx dialect
Projects
None yet
Development

No branches or pull requests

3 participants