From 580fad79940663d7d1bbaf75063d4ebf0c158556 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 19 Jun 2009 09:41:54 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/DelayComputation.java | 147 ++++++++++++++++-- Robust/src/IR/Flat/BuildCode.java | 2 +- 2 files changed, 132 insertions(+), 17 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index fa765069..8bc4713f 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -8,6 +8,7 @@ import Analysis.Loops.GlobalFieldType; import java.util.HashSet; import java.util.Hashtable; import java.util.Set; +import java.util.Stack; import java.util.Iterator; public class DelayComputation { @@ -16,12 +17,18 @@ public class DelayComputation { TypeAnalysis typeanalysis; GlobalFieldType gft; DiscoverConflicts dcopts; + Hashtable> notreadymap; + Hashtable> cannotdelaymap; + Hashtable> othermap; public DelayComputation(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis, GlobalFieldType gft) { this.locality=locality; this.state=state; this.typeanalysis=typeanalysis; this.gft=gft; + this.notreadymap=new Hashtable>(); + this.cannotdelaymap=new Hashtable>(); + this.othermap=new Hashtable>(); } public DiscoverConflicts getConflicts() { @@ -35,6 +42,127 @@ public class DelayComputation { } } + public HashSet getNotReady(LocalityBinding lb) { + return notreadymap.get(lb); + } + + public HashSet getCannotDelay(LocalityBinding lb) { + return cannotdelaymap.get(lb); + } + + public HashSet getOther(LocalityBinding lb) { + return othermap.get(lb); + } + + //This method computes which nodes from the first part of the + //transaction must store their output for the second part + //Note that many nodes don't need to... + + public Set livecode(LocalityBinding lb) { + if (!othermap.containsKey(lb)) + return null; + HashSet delayedset=notreadymap.get(lb); + MethodDescriptor md=lb.getMethod(); + FlatMethod fm=state.getMethodFlat(md); + Hashtable>> map=new Hashtable>>(); + + HashSet toanalyze=new HashSet(); + toanalyze.add(fm); + + HashSet livenodes=new HashSet(); + + while(!toanalyze.isEmpty()) { + FlatNode fn=toanalyze.iterator().next(); + toanalyze.remove(fn); + Hashtable> tmptofn=new Hashtable>(); + + //Do merge on incoming edges + for(int i=0;i> prevmap=map.get(fnprev); + + for(Iterator tmpit=prevmap.keySet().iterator();tmpit.hasNext();) { + TempDescriptor tmp=tmpit.next(); + if (!tmptofn.containsKey(tmp)) + tmptofn.put(tmp, new HashSet()); + tmptofn.get(tmp).addAll(prevmap.get(tmp)); + } + } + + if (delayedset.contains(fn)) { + //Check our readset + TempDescriptor readset[]=fn.readsTemps(); + for(int i=0;i set=new HashSet(); + set.add(fn); + tmptofn.put(tmp,set); + } + if (fn.numNext()>1) { + //We have a conditional branch...need to handle this carefully + Set set0=getNext(fn, 0, delayedset); + Set set1=getNext(fn, 1, delayedset); + if (!set0.equals(set1)||set0.size()>1) { + //This branch is important--need to remember how it goes + livenodes.add(fn); + } + } + } + if (!map.containsKey(fn)||!map.get(fn).equals(tmptofn)) { + map.put(fn, tmptofn); + //enqueue next ndoes + for(int i=0;i getNext(FlatNode fn, int i, HashSet delayset) { + FlatNode fnnext=fn.getNext(i); + HashSet reachable=new HashSet(); + + if (delayset.contains(fnnext)) { + reachable.add(fnnext); + return reachable; + } + Stack nodes=new Stack(); + HashSet visited=new HashSet(); + nodes.push(fnnext); + + while(!nodes.isEmpty()) { + FlatNode fn2=nodes.pop(); + if (visited.contains(fn2)) + continue; + visited.add(fn2); + for (int j=0;j