calyx icon indicating copy to clipboard operation
calyx copied to clipboard

`group2invoke` disables a bunch of passes

Open rachitnigam opened this issue 2 years ago • 4 comments

The MergeStaticPar and StaticParConv only act upon groups and cannot be run on invoke statements. Since group2invoke turns a lot of simple groups into invoke statements, these passes are less effective. We should probably redesign the pass pipeline so that these passes run after compile-invoke

rachitnigam avatar Aug 02 '22 16:08 rachitnigam

Once I get LiveRangeAnalysis to Handle Comb Groups, here's what I was thinking (for the ordering of the pre-opt passes). CompileInvoke is currently in compile but I have moved it to pre-opt:

GroupToSeq,
GroupToInvoke, // Creates Dead Groups potentially
ComponentInliner,
CombProp,
CompileRef, //Must run before cell-share.
InferShare,
CellShare, // LiveRangeAnalaysis must handle comb groups
RemoveCombGroups, // Must run before infer-static-timing
InferStaticTiming,
CompileInvoke
MergeStaticPar,
StaticParConv,    // Must be before collapse-control
DeadGroupRemoval, // Since MergeStaticPar and GroupToInvoke potentially create dead groups
CollapseControl,

calebmkim avatar Aug 04 '22 20:08 calebmkim

Does LRA handle comb groups? Also, if we can move somehow move compile-invoke to before remove-comb-groups, we can get rid of the extra cycle cost we have to pay for the invoke-with syntax

rachitnigam avatar Aug 05 '22 14:08 rachitnigam

  1. LRA doesn't handle comb groups yet, although I can start working on that-- we can discuss more synchronously, but I've been thinking about it like this: for invoke _ with comb group we can just set all components used in comb group as live in the invoke. for if _ with comb group or while _ with comb group we can analyze the live set at the comb group itself. In other words, comb groups that go w/ if and while statements should be treated as their own "nodes" in the LiveRangeAnalysis.

  2. I think just moving compile-invoke to be right before remove-comb-groups should work, unless there's some problem with that that I'm missing. I wasn't thinking about the timing we would save from that.

calebmkim avatar Aug 05 '22 15:08 calebmkim

Currently infer-static-timing benefits from having invokes since it can simply copy the latency of the component to the static time of the invoke. If we do compile-invoke beforehand, we lost thing but it might be a worthwhile trade-off

rachitnigam avatar Aug 08 '22 12:08 rachitnigam

@calebmkim am I misremember or did you open a PR to fix this during the summer?

rachitnigam avatar Sep 28 '22 23:09 rachitnigam

So https://github.com/cucapra/calyx/pull/1144 handles this particular issue, in the sense that invokes are compiled into groups so that the MergeStaticPar and StaticParConv passes see groups. However, there may be some work to do in terms of improving the ordering of the passes even more.

calebmkim avatar Sep 29 '22 19:09 calebmkim

Okay, let's close this particular issue in that case

rachitnigam avatar Sep 30 '22 04:09 rachitnigam