Skip to content
Snippets Groups Projects

Fork fission

Merged Xavier Routh requested to merge fork-fission into main
5 files
+ 51
21
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -310,23 +310,33 @@ pub fn fork_fission<'a>(
@@ -310,23 +310,33 @@ pub fn fork_fission<'a>(
reduce_cycles: &HashMap<NodeID, HashSet<NodeID>>,
reduce_cycles: &HashMap<NodeID, HashSet<NodeID>>,
loop_tree: &LoopTree,
loop_tree: &LoopTree,
fork_join_map: &HashMap<NodeID, NodeID>,
fork_join_map: &HashMap<NodeID, NodeID>,
 
fork_label: LabelID,
) -> Vec<NodeID> {
) -> Vec<NodeID> {
let mut forks: Vec<_> = loop_tree
let forks: Vec<_> = loop_tree
.bottom_up_loops()
.bottom_up_loops()
.into_iter()
.into_iter()
.filter(|(k, _)| editor.func().nodes[k.idx()].is_fork())
.filter(|(k, _)| editor.func().nodes[k.idx()].is_fork())
.collect();
.collect();
let mut created_forks = Vec::new();
let mut created_forks = Vec::new();
 
// This does the reduction fission
// This does the reduction fission
for fork in forks.clone() {
for fork in forks {
let join = fork_join_map[&fork.0];
let join = fork_join_map[&fork.0];
 
 
// FIXME: Don't make multiple forks for reduces that are in cycles with each other.
let reduce_partition = default_reduce_partition(editor, fork.0, join);
let reduce_partition = default_reduce_partition(editor, fork.0, join);
 
if !editor.func().labels[fork.0.idx()].contains(&fork_label) {
 
continue;
 
}
 
if editor.is_mutable(fork.0) {
if editor.is_mutable(fork.0) {
created_forks = fork_reduce_fission_helper(editor, fork_join_map, reduce_partition, nodes_in_fork_joins, fork.0);
created_forks = fork_reduce_fission_helper(editor, fork_join_map, reduce_partition, nodes_in_fork_joins, fork.0);
if !created_forks.is_empty() {
if created_forks.is_empty() {
break;
continue;
 
} else {
 
return created_forks;
}
}
}
}
Loading