From: adash Date: Tue, 23 Oct 2007 19:36:03 +0000 (+0000) Subject: bug fixes and new code for analysis of FlatFieldNode X-Git-Tag: preEdgeChange~408 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=21c957967fef4fcbafba8f01a2a9e4f27f7ae781;p=IRC.git bug fixes and new code for analysis of FlatFieldNode --- diff --git a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java index 2870afbd..940449a6 100644 --- a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java +++ b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java @@ -50,7 +50,6 @@ public class PrefetchAnalysis { Hashtable nodehash = new Hashtable(); FlatNode fn = (FlatNode)tovisit.iterator().next(); tovisit.remove(fn); - //System.out.println("DEBUG -> kind = " + fn.kind()); // Do self node prefetch doNodePrefetch(fn); // Do the child node analysis @@ -59,6 +58,7 @@ public class PrefetchAnalysis { } private void doNodePrefetch(FlatNode fn) { + //System.out.println("DEBUG -> kind = " + fn.kind()); Hashtable nodehash = new Hashtable(); switch(fn.kind()) { case FKind.FlatFieldNode: @@ -68,8 +68,9 @@ public class PrefetchAnalysis { FieldDescriptor currffn_field = currffn.getField(); TempDescriptor currffn_src = currffn.getSrc(); if (currffn_field.getType().isPtr()) { - System.out.println("\t pointer " + currffn_field.toString()); - PrefetchPair pp = new PrefetchPair(currffn_src, (Descriptor) currffn_field, false); + Boolean b = new Boolean(false); + PrefetchPair pp = new PrefetchPair(currffn_src, (Descriptor) currffn_field, b); + //PrefetchPair pp = new PrefetchPair(currffn_src, currffn_field, false); Float prob = new Float((double)1.0); nodehash.put(pp, prob); prefetch_hash.put(fn, nodehash); @@ -100,32 +101,48 @@ public class PrefetchAnalysis { Hashtable child_hash = prefetch_hash.get(child_node); switch(curr.kind()) { case FKind.FlatFieldNode: + //processFlatFieldNode(child_hash, curr); break; case FKind.FlatElementNode: break; + case FKind.FlatCall: + break; + case FKind.FlatCondBranch: + break; + case FKind.FlatNew: + break; + case FKind.FlatOpNode: + break; + case FKind.FlatSetElementNode: + break; + case FKind.FlatSetFieldNode: + break; default: + /*If FlatNode is not concerned with the prefetch set of its Child then propagate + * prefetches up the FlatNode*/ if (prefetch_hash.containsKey(curr)) { isCurrMod = true; - Hashtable parentcopy = prefetch_hash.get(curr); + Hashtable currentcopy = prefetch_hash.get(curr); Hashtable tocompare = new Hashtable(); - Enumeration e = parentcopy.keys(); + Enumeration e = currentcopy.keys(); while (e.hasMoreElements()) { PrefetchPair pp = (PrefetchPair) e.nextElement(); if (child_hash.contains(pp)) { Float cprob = child_hash.get(pp); - Float fprob = parentcopy.get(pp); + Float fprob = currentcopy.get(pp); // TODO fix this Float newprob = cprob.floatValue() * fprob.floatValue(); tocompare.put(pp, newprob); child_hash.remove(pp); } else { - tocompare.put(pp, parentcopy.get(pp)); + tocompare.put(pp, currentcopy.get(pp)); } } - e = child_hash.keys(); - while (e.hasMoreElements()) { - tocompare.put((PrefetchPair) e.nextElement(), child_hash.get((PrefetchPair) e.nextElement())); + for(e = child_hash.keys(); e.hasMoreElements();) { + PrefetchPair newpp = (PrefetchPair) e.nextElement(); + tocompare.put(newpp, child_hash.get(newpp)); } + } else { prefetch_hash.put(curr, child_hash); } @@ -135,6 +152,87 @@ public class PrefetchAnalysis { return isCurrMod; } + void processFlatFieldNode(Hashtable child_hash, FlatNode curr) { + boolean isCurrMod = false; + Hashtable currcopy = prefetch_hash.get(curr); + Hashtable tocompare = new Hashtable(); + ArrayList arrypp = new ArrayList(); + FlatFieldNode currffn = (FlatFieldNode) curr; + Float newprob = new Float((double)1.0); + + //1.Get each prefetch pair of the child and match it with the destination temp descriptor of curr FlatFieldNode + Enumeration ecld = child_hash.keys(); + PrefetchPair currpp = null; + PrefetchPair childpp = null; + while (ecld.hasMoreElements()) { + //PrefetchPair pp = (PrefetchPair) ecld.nextElement(); + childpp = (PrefetchPair) ecld.nextElement(); + if (childpp.base == currffn.getDst()) { + if (currffn.getField().getType().isPtr()) { + isCurrMod = true; + //if match exists then create a new Prefetch set with the new prefetch pair in a new hash table + System.out.println("Match with the parent base"); + System.out.print(childpp.base.toString()); + ArrayList newdesc = new ArrayList(); + ArrayList newbool = new ArrayList(); + newdesc.add(currffn.getField()); + Boolean b = new Boolean(false); + newbool.add(b); + newdesc.addAll(childpp.desc); + newbool.addAll(childpp.isTemp); + PrefetchPair newpp = new PrefetchPair(currffn.getSrc(), newdesc, newbool); + tocompare.put(newpp, newprob); + child_hash.remove(childpp); + } + } + } + /* Check if curr prefetch set and the child prefetch set have same prefetch pairs + * if so calculate the new probability and then remove the common one from the child prefetch set */ + ecld = child_hash.keys(); + Enumeration e = currcopy.keys(); + while(ecld.hasMoreElements()) { + childpp = (PrefetchPair) ecld.nextElement(); + for(e = currcopy.keys(); e.hasMoreElements();) { + currpp = (PrefetchPair) e.nextElement(); + if(currpp.equals(childpp)) { + /* Calculate the new probability */ + Float cprob = child_hash.get(childpp); + Float fprob = currcopy.get(currpp); + // TODO fix this + Float prob = cprob.floatValue() * fprob.floatValue(); + currcopy.put(currpp, prob); + child_hash.remove(childpp); + break; + } + } + } + + /* Merge child prefetch pairs */ + ecld = child_hash.keys(); + while(ecld.hasMoreElements()) { + childpp = (PrefetchPair) ecld.nextElement(); + tocompare.put(childpp, child_hash.get(childpp)); + } + + /* Merge curr prefetch pairs */ + e = currcopy.keys(); + while(e.hasMoreElements()) { + currpp = (PrefetchPair) e.nextElement(); + tocompare.put(currpp, currcopy.get(currpp)); + } + + //2. Compare with the orginal entry of the hashtable + //3. If same as old then do nothing + //4. If not same then enque parent nodes + //5. Process parent nodes into the hashtable + + + } + + void printPrefetchPair(Hashtable> outertable) { + + } + private void doAnalysis() { Iterator classit=state.getClassSymbolTable().getDescriptorsIterator(); while(classit.hasNext()) { @@ -144,7 +242,6 @@ public class PrefetchAnalysis { /* Classify parameters */ MethodDescriptor md=(MethodDescriptor)methodit.next(); FlatMethod fm=state.getMethodFlat(md); - System.out.println("DEBUG -> "); printMethod(fm); } } @@ -164,7 +261,6 @@ public class PrefetchAnalysis { FlatNode fn=(FlatNode)tovisit.iterator().next(); tovisit.remove(fn); visited.add(fn); - System.out.println("DEBUG -> " + fn.kind()); for(int i=0;i desc; - List isTemp; + ArrayList desc; + ArrayList isTemp; public PrefetchPair() { } public PrefetchPair(TempDescriptor t, Descriptor f, Boolean type) { base = t; + if (desc == null) + desc = new ArrayList(); + if (isTemp == null) + isTemp = new ArrayList(); desc.add(f); isTemp.add(type); } + public PrefetchPair(TempDescriptor t, ArrayList descriptor, ArrayList bool) { + base = t; + if(desc == null){ + desc = new ArrayList(); + } + if(isTemp == null) + isTemp = new ArrayList(); + desc.addAll(descriptor); + isTemp.addAll(bool); + } + public TempDescriptor getBase() { return base; }