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

Separate Inference and Promotion into Separate Passes #1871

Merged
merged 17 commits into from
Jan 29, 2024
Prev Previous commit
Next Next commit
updated code
calebmkim committed Jan 25, 2024
commit 442232b875b6482e28e576c1b9fc5ef30f00ea01
37 changes: 35 additions & 2 deletions calyx-opt/src/analysis/static_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::analysis::{
compute_static::WithStatic, GraphAnalysis, ReadWriteSet,
};
use calyx_ir::{self as ir, RRC};
use calyx_ir::{self as ir, GetAttributes, RRC};
use ir::CellType;
use itertools::Itertools;
use std::collections::HashMap;
@@ -44,7 +44,7 @@
}

/// Iterate over the defined ports
pub fn len(&self) -> usize {

Check failure on line 47 in calyx-opt/src/analysis/static_info.rs

GitHub Actions / Check Formatting

struct `GoDone` has a public `len` method, but no `is_empty` method
self.ports.len()
}

@@ -394,6 +394,36 @@
}
}

/// Removes the @promotable attribute.
fn remove_promotable_attribute(c: &mut ir::Control) {
c.get_mut_attributes().remove(ir::NumAttr::PromoteStatic);
match c {
ir::Control::Empty(_)
| ir::Control::Invoke(_)
| ir::Control::Enable(_)
| ir::Control::Static(_) => (),
ir::Control::While(ir::While { body, .. })
| ir::Control::Repeat(ir::Repeat { body, .. }) => {
Self::remove_promotable_attribute(body);
}
ir::Control::If(ir::If {
tbranch, fbranch, ..
}) => {
Self::remove_promotable_attribute(tbranch);
Self::remove_promotable_attribute(fbranch);
}
ir::Control::Seq(ir::Seq { stmts, .. })
| ir::Control::Par(ir::Par { stmts, .. }) => {
for stmt in stmts {
Self::remove_promotable_attribute(stmt);
}
}
}
}

// "Fixes Up" the component.
// Note that this only fixes up the components' *internals*. It does *not* fix
// up the component's signature.
pub fn fixup_timing(
&self,
comp: &mut ir::Component,
@@ -416,6 +446,9 @@
}
}

// Removing @promotable annotations for the entire control flow.
Self::remove_promotable_attribute(&mut comp.control.borrow_mut());

// Re-infering the latency of all the groups
for group in comp.get_groups() {
let latency_result = self.infer_latency(&group.borrow());
@@ -428,7 +461,7 @@
}
}

// Propogate control information.
// Re-infer control.
comp.control
.borrow_mut()
.update_static(&self.static_component_latencies);
4 changes: 0 additions & 4 deletions calyx-opt/src/passes/static_promotion.rs
Original file line number Diff line number Diff line change
@@ -541,10 +541,6 @@
}
}
}
// if comp.is_static() {
// self.static_component_latencies
// .insert(comp.name, comp.latency.unwrap());
// }
Ok(Action::Continue)
}

@@ -690,7 +686,7 @@
// Split the par into static and dynamic stmts, and use heuristics
// to choose whether to promote the static ones.
let (s_stmts, d_stmts): (Vec<ir::Control>, Vec<ir::Control>) =
s.stmts.drain(..).partition(|c| Self::can_be_promoted(&c));

Check failure on line 689 in calyx-opt/src/passes/static_promotion.rs

GitHub Actions / Check Formatting

this expression creates a reference which is immediately dereferenced by the compiler
new_stmts.extend(self.promote_vec_par_heuristic(&mut builder, s_stmts));
new_stmts.extend(d_stmts);
let new_par = ir::Control::Par(ir::Par {

Unchanged files with check annotations Beta

_comps: &[ir::Component],
) -> VisResult {
if comp.name != "main" {
match FixUp::get_possible_latency(&comp.control.borrow()) {

Check failure on line 86 in calyx-opt/src/passes/static_inference.rs

GitHub Actions / Check Formatting

you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
Some(val) => {
let comp_sig = comp.signature.borrow();
let mut done_ports: Vec<_> = comp_sig