From: adash Date: Fri, 7 Dec 2007 18:42:17 +0000 (+0000) Subject: added test files X-Git-Tag: preEdgeChange~343 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fcc84b34c70acfc033210afea3edf67fde68649d;p=IRC.git added test files C code for prefetch- still needs some work other minor changes --- diff --git a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java index c62040a4..94210be7 100644 --- a/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java +++ b/Robust/src/Analysis/Prefetch/PrefetchAnalysis.java @@ -115,6 +115,7 @@ public class PrefetchAnalysis { if(newprefetchset.size() > 0) { addFlatPrefetchNode(newprefetchset); } + //printMethod(fm); } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 7d484a85..61d1a2d6 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -33,6 +33,7 @@ public class BuildCode { public static boolean GENERATEPRECISEGC=false; public static String PREFIX=""; public static String arraytype="ArrayObject"; + public static int count = 0; Virtual virtualcalls; TypeUtil typeutil; private int maxtaskparams=0; @@ -1421,37 +1422,128 @@ public class BuildCode { } public void generateFlatPrefetchNode(FlatMethod fm, LocalityBinding lb, FlatPrefetchNode fpn, PrintWriter output) { - System.out.println("Inside generateFlatPrefetchNode()"); - if (state.PREFETCH) { - System.out.println("The Prefetch pairs to be fetched are "+ fpn.hspp); - Iterator it = fpn.hspp.iterator(); - for(;it.hasNext();) { - PrefetchPair pp = (PrefetchPair) it.next(); - //TODO handle arrays in prefetch tuples, currently only handle fields - Integer statusbase = locality.getNodePreTempInfo(lb,fpn).get(pp.base); - System.out.println("DEBUG-> generateFlatPrefetchNode()" + statusbase); - if(statusbase == LocalityAnalysis.GLOBAL) { - // Generate oid for base - } else { - for(int i = 0; i generateFlatPrefetchNode() fd" + statusfd); - //find out the locality of the fieldDescriptor - if(statusfd == LocalityAnalysis.GLOBAL) { - //generate oid for it - } - } - } - } - } - //Each temp descriptor can be an oid - //Find locality of each prefetch tuple in the FLatPrefetchNode - //Separate them as Local or Global - //generate oids and offset value for prefetch tuple - } + System.out.println("DEBUG -> Inside generateFlatPrefetchNode() " + fm.toString()); + short[] arrayfields = null; + Vector fieldoffset = new Vector(); + Vector oids = new Vector(); + short offsetcount = 0; + int tuplecount = 0; + int i; + + if (state.PREFETCH) { + System.out.println("The Prefetch pairs to be fetched are "+ fpn.hspp); + Iterator it = fpn.hspp.iterator(); + output.println("/* prefetch */"); + /* TODO Get rid of this */ + /* The while loop below removes all prefetch tuples with arrays from the set of prefetches */ + while(it.hasNext()) { + PrefetchPair pp = (PrefetchPair) it.next(); + for(i = 0; i < pp.desc.size(); i++) { + if(pp.getDescAt(i) instanceof IndexDescriptor) { + fpn.hspp.remove((PrefetchPair) pp); + it = fpn.hspp.iterator(); //May not be the best way ...replace coding in a better fashion + break; + } + } + } + output.println(" int numtuples_" + count + " = " + fpn.getNumPairs() + ";"); + int[] endoffsetarry = new int[fpn.getNumPairs()]; + output.print(" unsigned int oidarray_" + count + "[] = {"); + it = fpn.hspp.iterator(); + while(it.hasNext()) { + PrefetchPair pp = (PrefetchPair) it.next(); + offsetcount = 0; + //TODO handle arrays in prefetch tuples, currently only handle fields + Integer statusbase = locality.getNodePreTempInfo(lb,fpn).get(pp.base); + FieldDescriptor fd = (FieldDescriptor)pp.desc.get(0); + String oid = new String("(unsigned int) " + generateTemp(fm, pp.base, lb) + "->" + ((FieldDescriptor)fd).getSafeSymbol()); + oids.add(oid); + for(i = 1; i < pp.desc.size(); i++) { + Object desc = pp.desc.get(i); + offsetcount++; + TypeDescriptor newtd = ((FieldDescriptor)pp.getDescAt(i-1)).getType(); + String newfieldoffset = new String("(short)(&(((struct "+ newtd.getSafeSymbol()+" *)0)->"+ + ((FieldDescriptor)desc).getSafeSymbol()+ "))"); + fieldoffset.add(newfieldoffset); + } + if(tuplecount > 0) { + endoffsetarry[tuplecount] = endoffsetarry[tuplecount-1] + offsetcount; + }else { + endoffsetarry[tuplecount] = offsetcount; + } + + //if(statusbase == LocalityAnalysis.LOCAL) { + if(statusbase == LocalityAnalysis.GLOBAL) { + System.out.println("DEBUG-> Is Global"); + //Check to see if node is a inside or outside a transaction + /* + if(locality.getAtomic(lb).get(fpn).intValue() > 0) { + //TODO Is this correct ? or generate pointer code in C + // return; + } else { + output.println("/* PP: " + generateTemp(fm, pp.base, lb)); + } + */ + // Generate oid for base + } else { + for(i = 0; i generateFlatPrefetchNode() fd" + statusfd); + //find out the locality of the fieldDescriptor + if(statusfd == LocalityAnalysis.GLOBAL) { + //generate oid for it + } + } + } + } + tuplecount++; + } + + /*Create C code for oid array */ + boolean needcomma=false; + it = oids.iterator(); + while(it.hasNext()) { + if (needcomma) + output.print(", "); + output.print(it.next()); + needcomma=true; + } + output.println("};"); + + /*Create C code for endoffset values */ + output.print(" unsigned short endoffsetarry_" + count +"[] = {"); + needcomma=false; + for(i = 0; i"+ ffn.getField().getSafeSymbol()+";"); } else @@ -1778,7 +1870,7 @@ public class BuildCode { } else if (statusdst.equals(LocalityAnalysis.EITHER)) { //writing to a null...bad output.println("if ("+dst+") {"); - output.println("printf(\"BIG ERROR 2\n\");exit(-1);}"); + output.println("printf(\"BIG ERROR 2\\n\");exit(-1);}"); if (srcglobal) output.println(dst+"->"+ fsfn.getField().getSafeSymbol()+"=srcoid;"); else diff --git a/Robust/src/IR/Flat/FlatPrefetchNode.java b/Robust/src/IR/Flat/FlatPrefetchNode.java index 81a20d1d..c89bb90b 100644 --- a/Robust/src/IR/Flat/FlatPrefetchNode.java +++ b/Robust/src/IR/Flat/FlatPrefetchNode.java @@ -28,4 +28,8 @@ public class FlatPrefetchNode extends FlatNode { public HashSet getPrefetchPairs() { return hspp; } + + public int getNumPairs() { + return hspp.size(); + } } diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index d702c66b..08088586 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -1561,13 +1561,15 @@ void getPrefetchResponse(int count, int sd) { unsigned short getObjType(unsigned int oid) { objheader_t *objheader; - unsigned short numoffsets = 0; + unsigned short numoffset[] ={0}; + short fieldoffset[] ={}; if ((objheader = (objheader_t *) mhashSearch(oid)) == NULL) { if ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) { - prefetch(1, &oid, &numoffsets, NULL); + //prefetch(1, &oid, &numoffsets, NULL); + prefetch(1, &oid, numoffset, fieldoffset); pthread_mutex_lock(&pflookup.lock); while ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) { diff --git a/Robust/src/Tests/Atomic2.java b/Robust/src/Tests/Atomic2.java index 4dbf1736..c96ef202 100644 --- a/Robust/src/Tests/Atomic2.java +++ b/Robust/src/Tests/Atomic2.java @@ -3,7 +3,8 @@ public class Atomic2 extends Thread { } int count; public static void main(String[] st) { - int mid = (128<<24)|(200<<16)|(9<<8)|26; + //int mid = (128<<24)|(200<<16)|(9<<8)|26; + int mid = (128<<24)|(195<<16)|(175<<8)|70; Atomic2 t =null; atomic { t= global new Atomic2(); diff --git a/Robust/src/Tests/Atomic3.java b/Robust/src/Tests/Atomic3.java new file mode 100644 index 00000000..00128630 --- /dev/null +++ b/Robust/src/Tests/Atomic3.java @@ -0,0 +1,69 @@ +public class Atomic3 extends Thread { + public Atomic3() { + } + static Tree root; + Integer count; + public static void main(String[] st) { + int mid = (128<<24)|(195<<16)|(175<<8)|70; + int b; + Atomic3 at3 = null; + Integer z; + atomic { + at3 = global new Atomic3(); + z = global new Integer(300); + at3.root = global new Tree(); + at3.root.insert(z); + b = at3.root.value.intValue(); + } + atomic{ + at3.root.item = 2445; + } + System.printInt(b); + System.printString("\n"); + System.printString("Starting\n"); + at3.start(mid); + System.printString("Finished\n"); + while(true) { + ; + } + } + + public int run() { + int a; + atomic { + a = root.value.intValue(); + //a = root.item; + } + System.printInt(a); + System.printString("\n"); + } +} + +public class Tree { + public Integer value; + public int item; + public Tree left; + public Tree right; + + public Tree() { + } + + public Tree(Integer item) { + value = item; + left = null; + right = null; + } + + public Tree(Integer item , Tree l, Tree r) { + value = item; + left =l; + right = r; + } + + public Tree insert(Integer a) { + value = a; + left = null; + right = null; + return this; + } +} diff --git a/Robust/src/Tests/Prefetch/FieldPointer.java b/Robust/src/Tests/Prefetch/FieldPointer.java new file mode 100644 index 00000000..c490f03c --- /dev/null +++ b/Robust/src/Tests/Prefetch/FieldPointer.java @@ -0,0 +1,46 @@ +public class FieldPointer { + Account x; + public FieldPointer() { + } + + public static void main(String[] args) { + int bal; + FieldPointer fp = new FieldPointer(); + fp.x = new Account(); + fp.x.name = new String("TestAccount"); + fp.x.accountid = new Integer(12345); + fp.x.balance = new Item(); + fp.x.balance.i = new Integer(11000); + bal = fp.getBalance(fp.x.accountid); + if(bal < 7500) + bal = bal + fp.x.getBalance().intValue(); + else + bal = fp.x.getBalance().intValue(); + System.printInt(bal); + } + + public int getBalance(Integer accountid) { + if(accountid.intValue() > 12000) { + return 10000; + } else { + return 5000; + } + } +} + +public class Account { + String name; + Integer accountid; + Item balance; + public Account() { + } + public Integer getBalance() { + return balance.i; + } +} + +public class Item { + Integer i; + public Item() { + } +}