Skip to content
Snippets Groups Projects

Fork improvements

Merged rarbore2 requested to merge gcm_nested_parallel_forks into main
6 files
+ 78
12
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -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.
*/
@@ -349,6 +349,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
@@ -414,9 +435,8 @@ pub fn analyze_phis<'a>(
phis: &'a [NodeID],
loop_nodes: &'a HashSet<NodeID>,
) -> impl Iterator<Item = LoopPHI> + 'a {
// 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
@@ -465,7 +485,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());
@@ -513,7 +533,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