From fb3f0fa140fabf8351375988500d53e902f5c9bf Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 18 Jun 2009 22:16:38 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/DelayComputation.java | 123 +++++++++++++++--- .../Analysis/Locality/DiscoverConflicts.java | 17 +++ 2 files changed, 125 insertions(+), 15 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index 3708e6f9..fa765069 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -261,14 +261,26 @@ public class DelayComputation { if (isatomic) atomicset.add(fn); } - atomicset.removeAll(notreadyset); - atomicset.removeAll(cannotdelay); - System.out.println("-----------------------------------------------------"); - System.out.println(md); - System.out.println("Cannot delay set:"+cannotdelay); - System.out.println("Not ready set:"+notreadyset); - System.out.println("Other:"+atomicset); - + if (!atomicset.isEmpty()) { + atomicset.removeAll(notreadyset); + atomicset.removeAll(cannotdelay); + System.out.println("-----------------------------------------------------"); + System.out.println(md); + Hashtable map=new Hashtable(); + + for(Iterator it=atomicset.iterator();it.hasNext();) { + map.put(it.next(),"A"); + } + + for(Iterator it=notreadyset.iterator();it.hasNext();) { + map.put(it.next(),"2"); + } + + for(Iterator it=cannotdelay.iterator();it.hasNext();) { + map.put(it.next(),"1"); + } + System.out.println(fm.printMethod(map)); + } //We now have: //(1) Cannot delay set -- stuff that must be done before commit @@ -283,11 +295,13 @@ public class DelayComputation { 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 + //II. You access a field or element and + //(A). You are not in the cannot delay set + //(B). You read a field/element in the transactional set + //(C). The source didn't have a transactional read on it dcopts=new DiscoverConflicts(locality, state, typeanalysis); - + dcopts.doAnalysis(); MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); Hashtable atomictable=locality.getAtomic(lb); @@ -325,10 +339,89 @@ public class DelayComputation { } } - if (!notready&&!cannotdelay.contains(fn)&& - (fn.kind()==FKind.FlatFieldNode||fn.kind()==FKind.FlatElementNode)&& - dcopts.getNeedTrans(lb, fn)) { - notready=true; + if (!notready&&!cannotdelay.contains(fn)) { + switch(fn.kind()) { + case FKind.FlatFieldNode: { + FlatFieldNode ffn=(FlatFieldNode)fn; + if (!dcopts.getFields().contains(ffn.getField())) { + break; + } + TempDescriptor tmp=ffn.getSrc(); + Set tfpset=dcopts.getMap(lb).get(fn).get(tmp); + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (!dcopts.getNeedSrcTrans(lb, tfp.f)) { + //if a source didn't need a translation and we are + //accessing it, it did...so therefore we are note + //ready + notready=true; + break; + } + } + } + break; + } + case FKind.FlatSetFieldNode: { + FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; + TempDescriptor tmp=fsfn.getDst(); + Hashtable> tmpmap=dcopts.getMap(lb).get(fn); + Set tfpset=tmpmap!=null?tmpmap.get(tmp):null; + + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (!dcopts.getNeedSrcTrans(lb, tfp.f)) { + //if a source didn't need a translation and we are + //accessing it, it did...so therefore we are note + //ready + notready=true; + break; + } + } + } + break; + } + case FKind.FlatElementNode: { + FlatElementNode fen=(FlatElementNode)fn; + if (!dcopts.getArrays().contains(fen.getSrc().getType())) { + break; + } + TempDescriptor tmp=fen.getSrc(); + Set tfpset=dcopts.getMap(lb).get(fn).get(tmp); + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (!dcopts.getNeedSrcTrans(lb, tfp.f)) { + //if a source didn't need a translation and we are + //accessing it, it did...so therefore we are note + //ready + notready=true; + break; + } + } + } + break; + } + case FKind.FlatSetElementNode: { + FlatSetElementNode fsen=(FlatSetElementNode)fn; + TempDescriptor tmp=fsen.getDst(); + Set tfpset=dcopts.getMap(lb).get(fn).get(tmp); + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (!dcopts.getNeedSrcTrans(lb, tfp.f)) { + //if a source didn't need a translation and we are + //accessing it, it did...so therefore we are note + //ready + notready=true; + break; + } + } + } + break; + } + } } //Fix up things based on our status diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index ea40a392..7b45289a 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -24,6 +24,8 @@ public class DiscoverConflicts { Hashtable> rightsrcmap; TypeAnalysis typeanalysis; HashSetcannotdelay; + Hashtable>>> lbtofnmap; + public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis) { this.locality=locality; @@ -36,6 +38,7 @@ public class DiscoverConflicts { srcmap=new Hashtable>(); leftsrcmap=new Hashtable>(); rightsrcmap=new Hashtable>(); + lbtofnmap=new Hashtable>>>(); } public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis, HashSet cannotdelay) { @@ -50,6 +53,15 @@ public class DiscoverConflicts { srcmap=new Hashtable>(); leftsrcmap=new Hashtable>(); rightsrcmap=new Hashtable>(); + lbtofnmap=new Hashtable>>>(); + } + + public Set getFields() { + return fields; + } + + public Set getArrays() { + return arrays; } public void doAnalysis() { @@ -129,10 +141,15 @@ public class DiscoverConflicts { return treadmap.get(lb).contains(fn); } + public Hashtable>> getMap(LocalityBinding lb) { + return lbtofnmap.get(lb); + } + private void analyzeLocality(LocalityBinding lb) { MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); Hashtable>> fnmap=computeTempSets(lb); + lbtofnmap.put(lb,fnmap); HashSet tfset=computeTranslationSet(lb, fm, fnmap); HashSet srctrans=new HashSet(); HashSet leftsrctrans=new HashSet(); -- 2.34.1