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

Static promotion doesn't preserve semantics for shared resource dones on consecutive groups #2349

Open
ayakayorihiro opened this issue Nov 12, 2024 · 1 comment
Labels
C: calyx-opt Optimization or analysis pass Type: Bug Bug in the implementation

Comments

@ayakayorihiro
Copy link
Contributor

We found that static promotion doesn't preserve semantics when done signals of shared resources between two sequentially enabled groups are observed.

The below Calyx program has different outputs based on whether static promotion was enabled or not:

import "primitives/core.futil";
import "primitives/memories/comb.futil";

component main(@go go: 1) -> (@done done: 1) {
cells {
    @external(1) mem = comb_mem_d1(1, 1, 1);
    rr = std_reg(32);
}
wires {
    group g1 {
        rr.in = 32'd123;
        rr.write_en = 1'b1;
        g1[done] = rr.done;
    }
    group g2 {
        mem.addr0 = 1'b0;
        mem.write_en = 1'b1;
        mem.write_data = rr.done;
        g2[done] = mem.done;
    }
}
control { seq { g1; g2; } }
}

When running with static-promotion.futil.data while enabling static promotion, we get the result

$ fud2 static-promotion.futil --to dat --through verilator -s sim.data=static-promotion.futil.data
{
  "cycles": 2,
  "memories": {
    "mem": [
      1
    ]
  }
}

while when we disable static promotion, we get the result

$ fud2 static-promotion.futil --to dat --through verilator -s sim.data=static-promotion.futil.data -s calyx.args="-d static-promotion"
{
  "cycles": 4,
  "memories": {
    "mem": [
      0
    ]
  }
}

because there is an extra cycle between g1 and g2, which is when rr.done is 1; rr.done is 0 for the rest of the execution. But in static, there is no such extra cycle because g2 starts on the next cycle after g1.

@ayakayorihiro ayakayorihiro changed the title Static promotion doesn't preserve semantics on certain programs Static promotion doesn't preserve semantics for shared resource dones Nov 12, 2024
@ayakayorihiro ayakayorihiro changed the title Static promotion doesn't preserve semantics for shared resource dones Static promotion doesn't preserve semantics for shared resource dones on consecutive groups Nov 12, 2024
@ekiwi ekiwi added Type: Bug Bug in the implementation C: calyx-opt Optimization or analysis pass labels Nov 12, 2024
@ayakayorihiro
Copy link
Contributor Author

Just documenting some conclusions from our discussion today (please correct me if anything I say here is wrong):

  • Low/medium level: We should fix the situation in static by establishing a rule about when to not promote a group to static, and implementing it.
  • Higher level: We should figure out what we want our calling convention to look like in light of this situation, where things may occur/be used outside of the original group you used the resource in. Specifically, what should a successor group assume/expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: calyx-opt Optimization or analysis pass Type: Bug Bug in the implementation
Projects
None yet
Development

No branches or pull requests

2 participants