From: bdemsky Date: Mon, 13 Apr 2009 07:54:24 +0000 (+0000) Subject: changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ce611e3b42850886464e916a9c74acb87bfa9c67;p=IRC.git changes --- diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index b3444de6..cdb7c706 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -13,70 +13,81 @@ import IR.MethodDescriptor; import IR.FieldDescriptor; public class DiscoverConflicts { - Set fields; - Set arrays; - LocalityAnalysis locality; - State state; - - public DiscoverConflicts(LocalityAnalysis locality, State state) { - this.locality=locality; - this.fields=new HashSet(); - this.arrays=new HashSet(); - this.state=state; - transreadmap=new Hashtable>(); - srcmap=new Hashtable>(); - } + Set fields; + Set arrays; + LocalityAnalysis locality; + State state; + Hashtable> treadmap; + Hashtable> transreadmap; + Hashtable> srcmap; - public void doAnalysis() { - //Compute fields and arrays for all transactions - Set localityset=locality.getLocalityBindings(); - for(Iterator lb=localityset.iterator();lb.hasNext();) { - computeModified(lb.next()); - } - expandTypes(); - //Compute set of nodes that need transread - for(Iterator lb=localityset.iterator();lb.hasNext();) { - analyzeLocality(lb.next()); - } + public DiscoverConflicts(LocalityAnalysis locality, State state) { + this.locality=locality; + this.fields=new HashSet(); + this.arrays=new HashSet(); + this.state=state; + transreadmap=new Hashtable>(); + treadmap=new Hashtable>(); + srcmap=new Hashtable>(); + } + + public void doAnalysis() { + //Compute fields and arrays for all transactions + Set localityset=locality.getLocalityBindings(); + for(Iterator lb=localityset.iterator();lb.hasNext();) { + computeModified(lb.next()); } - public void expandTypes() { - //FIX ARRAY...compute super/sub sets of each so we can do simple membership test + expandTypes(); + //Compute set of nodes that need transread + for(Iterator lb=localityset.iterator();lb.hasNext();) { + LocalityBinding l=lb.next(); + analyzeLocality(l); + setNeedReadTrans(l); } + } - Hashtable> doMerge(FlatNode fn, Hashtable>> tmptofnset) { - Hashtable> table=new Hashtable>(); - for(int i=0;i> tabset=tmptofnset.get(fprev); - if (tabset!=null) { - for(Iterator tmpit=tabset.keySet().iterator();tmpit.hasNext();) { - TempDescriptor td=tmpit.next(); - Set fnset=tabset.get(td); - if (!table.containsKey(td)) - table.put(td, new HashSet()); - table.get(td).addAll(fnset); - } - } - } - return table; + public void setNeedReadTrans(LocalityBinding lb) { + HashSet set=new HashSet(); + for(Iterator it=transreadmap.get(lb).iterator();it.hasNext();) { + TempFlatPair tfp=it.next(); + set.add(tfp.f); } + treadmap.put(lb, set); + } - Hashtable> transreadmap; - Hashtable> srcmap; - - public Set getNeedSrcTrans(LocalityBinding lb) { - return srcmap.get(lb); - } + public void expandTypes() { + //FIX ARRAY...compute super/sub sets of each so we can do simple membership test + } - public Set getNeedReadTrans(LocalityBinding lb) { - HashSet set=new HashSet(); - for(Iterator it=transreadmap.get(lb).iterator();it.hasNext();) { - TempFlatPair tfp=it.next(); - set.add(tfp.f); + Hashtable> doMerge(FlatNode fn, Hashtable>> tmptofnset) { + Hashtable> table=new Hashtable>(); + for(int i=0;i> tabset=tmptofnset.get(fprev); + if (tabset!=null) { + for(Iterator tmpit=tabset.keySet().iterator();tmpit.hasNext();) { + TempDescriptor td=tmpit.next(); + Set fnset=tabset.get(td); + if (!table.containsKey(td)) + table.put(td, new HashSet()); + table.get(td).addAll(fnset); + } } - return set; } + return table; + } + + public Set getNeedSrcTrans(LocalityBinding lb) { + return srcmap.get(lb); + } + public boolean getNeedSrcTrans(LocalityBinding lb, FlatNode fn) { + return srcmap.get(lb).contains(fn); + } + + public boolean getNeedTrans(LocalityBinding lb, FlatNode fn) { + return treadmap.get(lb).contains(fn); + } private void analyzeLocality(LocalityBinding lb) { MethodDescriptor md=lb.getMethod(); @@ -96,12 +107,16 @@ public class DiscoverConflicts { case FKind.FlatSetFieldNode: { //definitely need to translate these FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; + if (!fsfn.getField().getType().isPtr()) + break; Set tfpset=tmap.get(fsfn.getSrc()); - for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { - TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)) { - srctrans.add(fsfn); - break; + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (tfset.contains(tfp)) { + srctrans.add(fsfn); + break; + } } } break; @@ -109,12 +124,16 @@ public class DiscoverConflicts { case FKind.FlatSetElementNode: { //definitely need to translate these FlatSetElementNode fsen=(FlatSetElementNode)fn; + if (!fsen.getSrc().getType().isPtr()) + break; Set tfpset=tmap.get(fsen.getSrc()); - for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { - TempFlatPair tfp=tfpit.next(); - if (tfset.contains(tfp)) { - srctrans.add(fsen); - break; + if (tfpset!=null) { + for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { + TempFlatPair tfp=tfpit.next(); + if (tfset.contains(tfp)) { + srctrans.add(fsen); + break; + } } } break; @@ -139,7 +158,8 @@ public class DiscoverConflicts { if (arrays.contains(fen.getSrc().getType())) { //this could cause conflict...figure out conflict set Set tfpset=tmap.get(fen.getSrc()); - tfset.addAll(tfpset); + if (tfpset!=null) + tfset.addAll(tfpset); } break; } @@ -148,7 +168,8 @@ public class DiscoverConflicts { if (fields.contains(ffn.getField())) { //this could cause conflict...figure out conflict set Set tfpset=tmap.get(ffn.getSrc()); - tfset.addAll(tfpset); + if (tfpset!=null) + tfset.addAll(tfpset); } break; } @@ -156,14 +177,16 @@ public class DiscoverConflicts { //definitely need to translate these FlatSetFieldNode fsfn=(FlatSetFieldNode)fn; Set tfpset=tmap.get(fsfn.getDst()); - tfset.addAll(tfpset); + if (tfpset!=null) + tfset.addAll(tfpset); break; } case FKind.FlatSetElementNode: { //definitely need to translate these FlatSetElementNode fsen=(FlatSetElementNode)fn; Set tfpset=tmap.get(fsen.getDst()); - tfset.addAll(tfpset); + if (tfpset!=null) + tfset.addAll(tfpset); break; } case FKind.FlatCall: //assume pessimistically that calls do bad things @@ -172,7 +195,8 @@ public class DiscoverConflicts { for(int i=0;i tfpset=tmap.get(rtmp); - tfset.addAll(tfpset); + if (tfpset!=null) + tfset.addAll(tfpset); } break; } @@ -233,9 +257,21 @@ public class DiscoverConflicts { } break; } + case FKind.FlatCall: + case FKind.FlatMethod: { + TempDescriptor[] writes=fn.writesTemps(); + for(int i=0;i set=new HashSet(); + set.add(new TempFlatPair(wtmp, fn)); + ttofn.put(wtmp, set); + } + break; + } case FKind.FlatOpNode: { FlatOpNode fon=(FlatOpNode)fn; - if (fon.getOp().getOp()==Operation.ASSIGN&&fon.getDest().getType().isPtr()) { + if (fon.getOp().getOp()==Operation.ASSIGN&&fon.getDest().getType().isPtr()&& + ttofn.containsKey(fon.getLeft())) { ttofn.put(fon.getDest(), new HashSet(ttofn.get(fon.getLeft()))); break; } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index d2090b4c..d925e1c5 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -17,6 +17,7 @@ import Analysis.TaskStateAnalysis.SafetyAnalysis; import Analysis.TaskStateAnalysis.TaskIndex; import Analysis.Locality.LocalityAnalysis; import Analysis.Locality.LocalityBinding; +import Analysis.Locality.DiscoverConflicts; import Analysis.Prefetch.*; import Analysis.Loops.WriteBarrier; @@ -52,6 +53,7 @@ public class BuildCode { HashSet setSESEtoGen; boolean nonSESEpass=true; WriteBarrier wb; + DiscoverConflicts dc; public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) { @@ -81,6 +83,10 @@ public class BuildCode { this.backuptable=new Hashtable>(); this.wb=new WriteBarrier(locality, st); } + if (state.SINGLETM) { + this.dc=new DiscoverConflicts(locality, st); + dc.doAnalysis(); + } setSESEtoGen = new HashSet(); } @@ -2186,7 +2192,8 @@ public class BuildCode { String dst=generateTemp(fm, ffn.getDst(),lb); output.println(dst+"="+ src +"->"+field+ ";"); - if (ffn.getField().getType().isPtr()&&locality.getAtomic(lb).get(ffn).intValue()>0) { + if (ffn.getField().getType().isPtr()&&locality.getAtomic(lb).get(ffn).intValue()>0&& + dc.getNeedTrans(lb, ffn)) { output.println("TRANSREAD("+dst+", "+dst+");"); } } else if (state.DSM) { @@ -2254,7 +2261,11 @@ public class BuildCode { String dst=generateTemp(fm,fsfn.getDst(),lb); if (srcptr&&!fsfn.getSrc().getType().isNull()) { output.println("{"); - output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);"); + if (dc.getNeedSrcTrans(lb, fsfn)) { + output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);"); + } else { + output.println("INTPTR srcoid=(INTPTR)"+src+"->"+oidstr+";"); + } } if (wb.needBarrier(fsfn)) output.println("*((unsigned int *)&("+dst+"->___objstatus___))|=DIRTY;"); @@ -2348,7 +2359,8 @@ public class BuildCode { String dst=generateTemp(fm, fen.getDst(),lb); output.println(dst +"=(("+ type+"*)(((char *) &("+ generateTemp(fm,fen.getSrc(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fen.getIndex(),lb)+"];"); - if (elementtype.isPtr()&&locality.getAtomic(lb).get(fen).intValue()>0) { + if (elementtype.isPtr()&&locality.getAtomic(lb).get(fen).intValue()>0&& + dc.getNeedTrans(lb, fen)) { output.println("TRANSREAD("+dst+", "+dst+");"); } } else if (state.DSM) { @@ -2403,7 +2415,11 @@ public class BuildCode { if (fsen.getSrc().getType().isPtr()&&!fsen.getSrc().getType().isNull()) { output.println("{"); String src=generateTemp(fm, fsen.getSrc(), lb); - output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);"); + if (dc.getNeedSrcTrans(lb, fsen)) { + output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);"); + } else { + output.println("INTPTR srcoid=(INTPTR)"+src+"->"+oidstr+";"); + } output.println("((INTPTR*)(((char *) &("+ generateTemp(fm,fsen.getDst(),lb)+"->___length___))+sizeof(int)))["+generateTemp(fm, fsen.getIndex(),lb)+"]=srcoid;"); output.println("}"); } else { diff --git a/Robust/src/IR/Flat/FlatMethod.java b/Robust/src/IR/Flat/FlatMethod.java index 0cd5e7b2..cc60be51 100644 --- a/Robust/src/IR/Flat/FlatMethod.java +++ b/Robust/src/IR/Flat/FlatMethod.java @@ -33,6 +33,16 @@ public class FlatMethod extends FlatNode { } else { ret += task.toString(); } + ret+="("; + boolean first=true; + for(int i=0;i