From 8173c408c8d82e44d6afe5c61ebe14d15a192162 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 18 Jun 2009 00:02:48 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/DelayComputation.java | 8 +- .../Analysis/Locality/DiscoverConflicts.java | 78 +++++++++++++------ 2 files changed, 62 insertions(+), 24 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 211f6659..e91fa3cf 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -273,12 +273,16 @@ public class DelayComputation { //(3) everything else -- stuff that should be done before commit } //end of method + //Problems: + //1) we acquire locks too early to object we don't need to yet + //2) we don't realize that certain operations have side effects + public HashSet computeNotReadySet(LocalityBinding lb, HashSet cannotdelay) { //You are in not ready set if: //I. You read a not ready temp - //II. You read a field or element and both (A) you are not in the //cannot delay set and (B) you do a transactional access to object + MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); Hashtable atomictable=locality.getAtomic(lb); @@ -351,4 +355,4 @@ public class DelayComputation { } //end of while return notreadynodes; } //end of computeNotReadySet -} //end of class \ No newline at end of file +} //end of class diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index 87930f3a..ea40a392 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -23,7 +23,8 @@ public class DiscoverConflicts { Hashtable> leftsrcmap; Hashtable> rightsrcmap; TypeAnalysis typeanalysis; - + HashSetcannotdelay; + public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis) { this.locality=locality; this.fields=new HashSet(); @@ -36,6 +37,20 @@ public class DiscoverConflicts { leftsrcmap=new Hashtable>(); rightsrcmap=new Hashtable>(); } + + public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis, HashSet cannotdelay) { + this.locality=locality; + this.fields=new HashSet(); + this.arrays=new HashSet(); + this.state=state; + this.typeanalysis=typeanalysis; + this.cannotdelay=cannotdelay; + transreadmap=new Hashtable>(); + treadmap=new Hashtable>(); + srcmap=new Hashtable>(); + leftsrcmap=new Hashtable>(); + rightsrcmap=new Hashtable>(); + } public void doAnalysis() { //Compute fields and arrays for all transactions. Note that we @@ -54,6 +69,8 @@ public class DiscoverConflicts { } } + //Change flatnode/temp pairs to just flatnodes that need transactional reads + public void setNeedReadTrans(LocalityBinding lb) { HashSet set=new HashSet(); for(Iterator it=transreadmap.get(lb).iterator();it.hasNext();) { @@ -133,6 +150,9 @@ public class DiscoverConflicts { if (atomictable.get(fn).intValue()>0) { Hashtable> tmap=fnmap.get(fn); switch(fn.kind()) { + + //We might need to translate arguments to pointer comparison + case FKind.FlatOpNode: { FlatOpNode fon=(FlatOpNode)fn; if (fon.getOp().getOp()==Operation.EQUAL|| @@ -145,7 +165,7 @@ public class DiscoverConflicts { if (lefttfpset!=null) { for(Iterator tfpit=lefttfpset.iterator();tfpit.hasNext();) { TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)||ok(tfp)) { + if (tfset.contains(tfp)||outofscope(tfp)) { leftsrctrans.add(fon); break; } @@ -155,7 +175,7 @@ public class DiscoverConflicts { if (righttfpset!=null) { for(Iterator tfpit=righttfpset.iterator();tfpit.hasNext();) { TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)||ok(tfp)) { + if (tfset.contains(tfp)||outofscope(tfp)) { rightsrctrans.add(fon); break; } @@ -164,8 +184,13 @@ public class DiscoverConflicts { } break; } + case FKind.FlatSetFieldNode: { - //definitely need to translate these + //need to translate these if the value we read from may be a + //shadow... check this by seeing if any of the values we + //may read are in the transread set or came from our caller + //or a method we called + FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; if (!fsfn.getField().getType().isPtr()) break; @@ -173,7 +198,7 @@ public class DiscoverConflicts { if (tfpset!=null) { for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)||ok(tfp)) { + if (tfset.contains(tfp)||outofscope(tfp)) { srctrans.add(fsfn); break; } @@ -182,7 +207,11 @@ public class DiscoverConflicts { break; } case FKind.FlatSetElementNode: { - //definitely need to translate these + //need to translate these if the value we read from may be a + //shadow... check this by seeing if any of the values we + //may read are in the transread set or came from our caller + //or a method we called + FlatSetElementNode fsen=(FlatSetElementNode)fn; if (!fsen.getSrc().getType().isPtr()) break; @@ -190,7 +219,7 @@ public class DiscoverConflicts { if (tfpset!=null) { for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)||ok(tfp)) { + if (tfset.contains(tfp)||outofscope(tfp)) { srctrans.add(fsen); break; } @@ -204,18 +233,29 @@ public class DiscoverConflicts { } } - public boolean ok(TempFlatPair tfp) { + public boolean outofscope(TempFlatPair tfp) { FlatNode fn=tfp.f; return fn.kind()==FKind.FlatCall||fn.kind()==FKind.FlatMethod; } - //compute set of nodes that need transread on their output + + /** Need to figure out which nodes need a transread to make local + copies. Transread conceptually tracks conflicts. This depends on + what fields/elements are accessed We iterate over all flatnodes that + access fields...If these accesses could conflict, we mark the source + tempflat pair as needing a transread */ + HashSet computeTranslationSet(LocalityBinding lb, FlatMethod fm, Hashtable>> fnmap) { HashSet tfset=new HashSet(); for(Iterator fnit=fm.getNodeSet().iterator();fnit.hasNext();) { FlatNode fn=fnit.next(); Hashtable atomictable=locality.getAtomic(lb); + + //Check whether this node matters for delayed computation + if (cannotdelay!=null&&!cannotdelay.contains(fn)) + continue; + if (atomictable.get(fn).intValue()>0) { Hashtable> tmap=fnmap.get(fn); switch(fn.kind()) { @@ -274,8 +314,12 @@ public class DiscoverConflicts { return tfset; } - //Map for each node from temps to the flatnode and (the temp) that - //first did a field/element read for this value + + //This method generates as output for each node + //A map from from temps to a set of temp/flat pairs that the + //original temp points to + //A temp/flat pair gives the flatnode that the value was created at + //and the original temp Hashtable>> computeTempSets(LocalityBinding lb) { Hashtable>> tmptofnset=new Hashtable>>(); @@ -301,18 +345,8 @@ public class DiscoverConflicts { Hashtable> ttofn=null; if (atomictable.get(fn).intValue()!=0) { if ((fn.numPrev()>0)&&atomictable.get(fn.getPrev(0)).intValue()==0) { - //flatatomic enter node... see what we really need to transread - //Set liveset=livetemps.get(fn); + //atomic node, start with new set ttofn=new Hashtable>(); - /* - for(Iterator tmpit=liveset.iterator();tmpit.hasNext();) { - TempDescriptor tmp=tmpit.next(); - if (tmp.getType().isPtr()) { - HashSet fnset=new HashSet(); - fnset.add(new TempFlatPair(tmp, fn)); - ttofn.put(tmp, fnset); - } - }*/ } else { ttofn=doMerge(fn, tmptofnset); switch(fn.kind()) { -- 2.34.1