Skip to content
Snippets Groups Projects

Fork fission bufferize

Merged Xavier Routh requested to merge fork-fission-bufferize into main
All threads resolved!
2 files
+ 20
2
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 17
2
use std::cell::Ref;
use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::iter::{empty, once, zip, FromIterator};
use bitvec::prelude::*;
@@ -76,6 +76,7 @@ pub fn gcm(
dom: &DomTree,
fork_join_map: &HashMap<NodeID, NodeID>,
loops: &LoopTree,
reduce_cycles: &HashMap<NodeID, HashSet<NodeID>>,
objects: &CollectionObjects,
devices: &Vec<Device>,
object_device_demands: &FunctionObjectDeviceDemands,
@@ -88,6 +89,7 @@ pub fn gcm(
reverse_postorder,
dom,
loops,
reduce_cycles,
fork_join_map,
objects,
devices,
@@ -173,6 +175,7 @@ fn basic_blocks(
reverse_postorder: &Vec<NodeID>,
dom: &DomTree,
loops: &LoopTree,
reduce_cycles: &HashMap<NodeID, HashSet<NodeID>>,
fork_join_map: &HashMap<NodeID, NodeID>,
objects: &CollectionObjects,
devices: &Vec<Device>,
@@ -246,6 +249,9 @@ fn basic_blocks(
// but not forwarding read - forwarding reads are collapsed, and the
// bottom read is treated as reading from the transitive parent of the
// forwarding read(s).
// 3: If the node producing the collection is a reduce node, then any read
// users that aren't in the reduce's cycle shouldn't anti-depend user any
// mutators in the reduce cycle.
let mut antideps = BTreeSet::new();
for id in reverse_postorder.iter() {
// Find a terminating read node and the collections it reads.
@@ -271,6 +277,10 @@ fn basic_blocks(
// TODO: make this less outrageously inefficient.
let func_objects = &objects[&func_id];
for root in roots.iter() {
let root_is_reduce_and_read_isnt_in_cycle = reduce_cycles
.get(root)
.map(|cycle| !cycle.contains(&id))
.unwrap_or(false);
let root_early = schedule_early[root.idx()].unwrap();
let mut root_block_iterated_users: BTreeSet<NodeID> = BTreeSet::new();
let mut workset = BTreeSet::new();
@@ -292,12 +302,17 @@ fn basic_blocks(
.collect();
for mutator in reverse_postorder.iter() {
let mutator_early = schedule_early[mutator.idx()].unwrap();
if dom.does_prop_dom(root_early, mutator_early)
if dom.does_dom(root_early, mutator_early)
&& (root_early != mutator_early
|| root_block_iterated_users.contains(&mutator))
&& mutating_objects(function, func_id, *mutator, objects)
.any(|mutated| read_objs.contains(&mutated))
&& id != mutator
&& (!root_is_reduce_and_read_isnt_in_cycle
|| !reduce_cycles
.get(root)
.map(|cycle| cycle.contains(mutator))
.unwrap_or(false))
{
antideps.insert((*id, *mutator));
}
Loading