Skip to content
Snippets Groups Projects
Commit 6a00ad37 authored by rarbore2's avatar rarbore2
Browse files

Fix issue #21

parent b17a5883
No related branches found
No related tags found
1 merge request!154Fix issue #21
...@@ -324,6 +324,12 @@ fn basic_blocks( ...@@ -324,6 +324,12 @@ fn basic_blocks(
// 3: If the node producing the collection is a reduce node, then any read // 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 // users that aren't in the reduce's cycle shouldn't anti-depend user any
// mutators in the reduce cycle. // mutators in the reduce cycle.
//
// Because we do a liveness analysis based spill of collections, anti-
// dependencies can be best effort. Thus, when we encounter a read and
// mutator where the read doesn't dominate the mutator, but an anti-depdence
// edge is derived for the pair, we just don't draw the edge since it would
// break the scheduler.
let mut antideps = BTreeSet::new(); let mut antideps = BTreeSet::new();
for id in reverse_postorder.iter() { for id in reverse_postorder.iter() {
// Find a terminating read node and the collections it reads. // Find a terminating read node and the collections it reads.
...@@ -385,6 +391,7 @@ fn basic_blocks( ...@@ -385,6 +391,7 @@ fn basic_blocks(
.get(root) .get(root)
.map(|cycle| cycle.contains(mutator)) .map(|cycle| cycle.contains(mutator))
.unwrap_or(false)) .unwrap_or(false))
&& dom.does_dom(schedule_early[id.idx()].unwrap(), mutator_early)
{ {
antideps.insert((*id, *mutator)); antideps.insert((*id, *mutator));
} }
......
...@@ -135,3 +135,29 @@ fn array_of_structs(input: i32) -> i32 { ...@@ -135,3 +135,29 @@ fn array_of_structs(input: i32) -> i32 {
arr[0].1 = 99; arr[0].1 = 99;
return result + sub.1 - arr[0].1; return result + sub.1 - arr[0].1;
} }
#[entry]
fn issue_21<n: usize>() -> i32 {
let visited: bool[n];
let cost: i32[n];
for i = 0 to n {
if visited[i] {
cost[i] = cost[i] + 1;
}
}
for i = 0 to n {
visited[i] = true;
}
let total : i32;
for i = 0 to n {
if visited[i] {
total += cost[i] + 2;
}
}
return total;
}
...@@ -3,7 +3,7 @@ phi-elim(*); ...@@ -3,7 +3,7 @@ phi-elim(*);
dce(*); dce(*);
let out = auto-outline(*); let out = auto-outline(*);
gpu(out.simple_antideps, out.loop_antideps, out.complex_antideps1, out.complex_antideps2, out.very_complex_antideps, out.read_chains, out.array_of_structs); gpu(out.simple_antideps, out.loop_antideps, out.complex_antideps1, out.complex_antideps2, out.very_complex_antideps, out.read_chains, out.array_of_structs, out.issue_21);
ip-sroa(*); ip-sroa(*);
sroa(*); sroa(*);
......
...@@ -40,6 +40,11 @@ fn main() { ...@@ -40,6 +40,11 @@ fn main() {
let output = r.run(2).await; let output = r.run(2).await;
println!("{}", output); println!("{}", output);
assert_eq!(output, 14); assert_eq!(output, 14);
let mut r = runner!(issue_21);
let output = r.run(42).await;
println!("{}", output);
assert_eq!(output, 42 * 2);
}); });
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment