Skip to content
Snippets Groups Projects

Fork fission bufferize

Merged Xavier Routh requested to merge fork-fission-bufferize into main
All threads resolved!
6 files
+ 78
15
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 27
10
@@ -10,8 +10,8 @@ use hercules_ir::*;
use crate::*;
/*
* TODO: Forkify currently makes a bunch of small edits - this needs to be
/*
* TODO: Forkify currently makes a bunch of small edits - this needs to be
* changed so that every loop that gets forkified corresponds to a single edit
* + sub-edits. This would allow us to run forkify on a subset of a function.
*/
@@ -350,6 +350,27 @@ pub fn forkify_loop(
};
let reduce_id = edit.add_node(reduce);
if (!edit.get_node(init).is_reduce()
&& edit.get_schedule(init).contains(&Schedule::ParallelReduce))
|| (!edit.get_node(continue_latch).is_reduce()
&& edit
.get_schedule(continue_latch)
.contains(&Schedule::ParallelReduce))
{
edit = edit.add_schedule(reduce_id, Schedule::ParallelReduce)?;
}
if (!edit.get_node(init).is_reduce()
&& edit
.get_schedule(init)
.contains(&Schedule::TightAssociative))
|| (!edit.get_node(continue_latch).is_reduce()
&& edit
.get_schedule(continue_latch)
.contains(&Schedule::TightAssociative))
{
edit = edit.add_schedule(reduce_id, Schedule::TightAssociative)?;
}
edit = edit.replace_all_uses_where(phi, reduce_id, |usee| *usee != reduce_id)?;
edit = edit.replace_all_uses_where(continue_latch, reduce_id, |usee| {
!loop_nodes.contains(usee) && *usee != reduce_id
@@ -417,12 +438,8 @@ pub fn analyze_phis<'a>(
phis: &'a [NodeID],
loop_nodes: &'a HashSet<NodeID>,
) -> impl Iterator<Item = LoopPHI> + 'a {
// We are also moving the phi from the top of the loop (the header),
// to the very end (the join). If there are uses of the phi somewhere in the loop,
// then they may try to use the phi (now a reduce) before it hits the join.
// Find data cycles within the loop of this phi,
// Start from the phis loop_continue_latch, and walk its uses until we find the original phi.
// Find data cycles within the loop of this phi,
// Start from the phis loop_continue_latch, and walk its uses until we find the original phi.
phis.into_iter().map(move |phi| {
let stop_on: HashSet<NodeID> = editor
@@ -471,7 +488,7 @@ pub fn analyze_phis<'a>(
.unwrap();
let loop_continue_latch = editor.node(phi).try_phi().unwrap().1[continue_idx];
let uses = walk_all_uses_stop_on(loop_continue_latch, editor, stop_on.clone());
let users = walk_all_users_stop_on(*phi, editor, stop_on.clone());
@@ -524,7 +541,7 @@ pub fn analyze_phis<'a>(
// If some other node in the cycle is used, there is not a valid node to assign it after making the cycle a reduce.
if intersection
.iter()
.filter(|node| **node != loop_continue_latch )
.filter(|node| **node != loop_continue_latch)
.any(|data_node| {
editor
.get_users(*data_node)
Loading