-
Notifications
You must be signed in to change notification settings - Fork 50
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
Group to Seq #1086
Group to Seq #1086
Conversation
Couple of questions about this pass, @rachitnigam.
(More code specific questions)
|
|
@rachitnigam (sorry to bother again)
This is giving me an error: Also, are there any other benefits to doing this in the |
The same group may be used from multiple
In this case, you'll end up re-running the analysis for each To iterate over groups, you have to "detach" it from the component:
Does that make sense? |
…ons such as weird go asmts
calyx/src/analysis/order_analysis.rs
Outdated
#[derive(Default)] | ||
///Primarily used to help determine the order cells are executed within | ||
///the group | ||
pub struct OrderAnalysis { |
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.
Is this implementing the same logic as InferStaticTiming
? If so, we should generalize those two
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.
There is some overlap between, mem_wrt_dep_graph
of InferStaticTiming
and update_map
of OrderAnalysis
but there are differences as well and in my opinion it's not worth it to try to generalize. Edit: But maybe generalizing is a good idea. It's just it doesn't seem like it would be on first glance.
calyx/src/passes/group_to_seq.rs
Outdated
second_group.borrow_mut().assignments.append(&mut snd_asmts); | ||
|
||
//renaming old_group[done] = ... to new_group[done] = ... | ||
let new_done = rename_group_done( |
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.
The right way to update a group's done condition is using Group::done_cond_mut
instead of manually editing the assignments. The latter is unsafe and will be deprecated
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.
If I create a group using builder.add_group()
, does it automatically come with a done assignment? Because when I try to use done_cond_mut
it's giving me an error and saying the group has no done condition.
calyx/src/default_passes.rs
Outdated
CollapseControl, | ||
CompileRef, //Must run before 'resource-sharing'. | ||
GroupToSeq, |
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.
You can run DeadGroupRemoval
again if you want in this pipeline
calyx/src/default_passes.rs
Outdated
CollapseControl, | ||
CompileRef, //Must run before 'resource-sharing'. | ||
GroupToSeq, | ||
CellShare, |
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.
Open an issue saying that we should run CellShare as early as possible, ideally before merge-static-par
. This cannot be done currently because it doesn't handle ref cells
passed into an invoke: https://docs.calyxir.org/lang/memories-by-reference.html#the-easy-way
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.
Okay, this is looking done! A couple of minor comments about structuring the interface for SplitAnalysis. Address it and merge at your discretion!
calyx/src/passes/group_to_seq.rs
Outdated
// Add back the groups we drained at the beginning of this method, but | ||
// filter out the empty groups that were split into smaller groups | ||
comp.groups.append(groups.into_iter().filter( | ||
|group: &ir::RRC<ir::Group>| !group.borrow().assignments.is_empty(), |
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.
No need to add the type of group
here
calyx/src/passes/group_to_seq.rs
Outdated
let mut builder = ir::Builder::new(comp, sigs); | ||
for g in groups.iter() { | ||
let mut group = g.borrow_mut(); | ||
match SplitAnalysis::get_split( |
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.
It seems like SplitAnalysis
returns two groups in the Ok
case. What if we make it take the group
directly instead of passing the assignments and the name? That way, we also avoid this drain(..).collect()
call.
@@ -1,18 +1,19 @@ | |||
import "primitives/core.futil"; | |||
import "primitives/binary_operators.futil"; | |||
component main(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { | |||
component main<"static"=5>(@go go: 1, @clk clk: 1, @reset reset: 1) -> (@done done: 1) { |
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.
Really cool effect of this pass that the component can have its static latency inferred!
@@ -0,0 +1,92 @@ | |||
// -p group2seq |
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.
Run -p validate
before group2seq
@@ -0,0 +1,43 @@ | |||
//-p canonicalize -p group2seq |
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.
Run validate
instead of canonicalize
@@ -0,0 +1,43 @@ | |||
//-p canonicalize -p group2seq |
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.
validate
instead of canonicalize
Transforms a big group into a seq of two smaller groups.
OrderAnalysis
is used to determine if we can even apply the transformation.I can writeup more details here, but part of me thinks it may be better to just discuss details in person.
Edit: Failing bc it's applying the transformation and that is changing some of the the things in the examples/ folder,
and changing the number of cycles for some of the correctness tests.
Edit2: Changed these tests to reflect my changes.