Skip to content

Commit

Permalink
slightly better guard
Browse files Browse the repository at this point in the history
  • Loading branch information
calebmkim committed Jul 14, 2024
1 parent a38529a commit 1b9595a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions calyx-opt/src/analysis/static_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ impl ParTree {
child.count_to_n(builder, incr_start_cond.clone());
}
}

pub fn get_longest_tree(&mut self) -> &mut Tree {
let max = self.threads.iter_mut().max_by_key(|(child, _)| {
(child.get_latency() * child.get_num_repeats()) as i64
Expand Down
30 changes: 28 additions & 2 deletions calyx-opt/src/passes/static_inliner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::analysis::GraphColoring;
use crate::passes::math_utilities::get_bit_width_from;
use crate::traversal::{Action, Named, VisResult, Visitor};
use calyx_ir::structure;
use calyx_ir::LibrarySignatures;
Expand Down Expand Up @@ -231,6 +232,17 @@ impl StaticInliner {
}
}

fn increase_sgroup_latency(sg: ir::RRC<ir::StaticGroup>, new_lat: u64) {
assert!(
new_lat >= sg.borrow().get_latency(),
"New latency must be bigger than existing latency"
);
sg.borrow_mut().latency = new_lat;
sg.borrow_mut().assignments.iter_mut().for_each(|asssign| {
asssign.guard.add_interval(StaticTiming::new((0, new_lat)))
});
}

// inlines the static control `sc` and returns an equivalent single static group
fn inline_static_control(
sc: &ir::StaticControl,
Expand Down Expand Up @@ -397,14 +409,28 @@ impl StaticInliner {
> = vec![];
for group in groups {
// Assign par_group[go] = %[0:par_latency] ? 1'd1;
if get_bit_width_from(group.borrow().latency)
== get_bit_width_from(*latency)
{
Self::increase_sgroup_latency(
Rc::clone(&group),
*latency,
);
}

structure!( builder;
let signal_on = constant(1,1);
);
let stmt_guard =

let stmt_guard = if group.borrow().latency == *latency {
ir::Guard::True
} else {
ir::Guard::Info(ir::StaticTiming::new((
0,
group.borrow().get_latency(),
)));
)))
};

let trigger_body = build_assignments!(builder;
group["go"] = stmt_guard ? signal_on["out"];
);
Expand Down

0 comments on commit 1b9595a

Please sign in to comment.