add support for scratch memory
authorbdemsky <bdemsky>
Tue, 14 Apr 2009 23:05:36 +0000 (23:05 +0000)
committerbdemsky <bdemsky>
Tue, 14 Apr 2009 23:05:36 +0000 (23:05 +0000)
12 files changed:
Robust/src/Analysis/Locality/GenerateConversions.java
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java
Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java
Robust/src/Benchmarks/SingleTM/LeeRouting/makefile
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Tree/BuildIR.java
Robust/src/Lex/Keyword.java
Robust/src/Lex/Lexer.java
Robust/src/Parse/java14.cup
Robust/src/Runtime/garbage.c
Robust/src/Runtime/thread.c

index 4e9d3d673a05beb4688668bfa0519ee48c129d9a..41bcc0e140ae244d63d09ad2fcc34735ad41522d 100644 (file)
@@ -49,7 +49,7 @@ public class GenerateConversions {
       toprocess.remove(fn);
       boolean isatomic=atomictab.get(fn).intValue()>0;
 
-      Hashtable<TempDescriptor, Integer> nodetemptab=state.DSM?temptab.get(fn):null;
+      Hashtable<TempDescriptor, Integer> nodetemptab=temptab.get(fn);
 
       List<TempDescriptor> reads=Arrays.asList(fn.readsTemps());
       List<TempDescriptor> writes=Arrays.asList(fn.writesTemps());
@@ -112,7 +112,8 @@ public class GenerateConversions {
          for(Iterator<TempDescriptor> writeit=writes.iterator(); writeit.hasNext();) {
            TempDescriptor wrtmp=writeit.next();
            if (state.SINGLETM) {
-             if (wrtmp.getType().isPtr()) {
+             if (wrtmp.getType().isPtr()&&
+                 (nodetemptab.get(wrtmp)!=LocalityAnalysis.SCRATCH)) {
                TempNodePair tnp=new TempNodePair(wrtmp);
                tempset.add(tnp);
              }
@@ -145,8 +146,7 @@ public class GenerateConversions {
          TempDescriptor tmpd=tempit.next();
          FlatGlobalConvNode fgcn=new FlatGlobalConvNode(tmpd, lb, false, nodetoconvs.get(fn).contains(tmpd));
          atomictab.put(fgcn, atomictab.get(fn));
-         if (state.DSM)
-           temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
+         temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
 
          FlatNode[] prevarray=new FlatNode[fn.numPrev()];
          for(int i=0; i<fn.numPrev(); i++) {
@@ -194,16 +194,17 @@ public class GenerateConversions {
        //subtract out the ones we write to
        transtemps.removeAll(Arrays.asList(fn.writesTemps()));
        //add in the globals we read from
+       Hashtable<TempDescriptor, Integer> pretemptab=locality.getNodePreTempInfo(lb, fn);
        if (state.SINGLETM) {
          TempDescriptor [] readtemps=fn.readsTemps();
          for(int i=0; i<readtemps.length; i++) {
            TempDescriptor tmp=readtemps[i];
-           if (tmp.getType().isPtr()) {
+           if (tmp.getType().isPtr()&&
+               pretemptab.get(tmp).intValue()!=LocalityAnalysis.SCRATCH) {
              transtemps.add(tmp);
            }
          }
        } else {
-         Hashtable<TempDescriptor, Integer> pretemptab=locality.getNodePreTempInfo(lb, fn);
          TempDescriptor [] readtemps=fn.readsTemps();
          for(int i=0; i<readtemps.length; i++) {
            TempDescriptor tmp=readtemps[i];
@@ -232,9 +233,7 @@ public class GenerateConversions {
        for(Iterator<TempDescriptor> tempit=tempset.iterator(); tempit.hasNext();) {
          FlatGlobalConvNode fgcn=new FlatGlobalConvNode(tempit.next(), lb, true);
          atomictab.put(fgcn, atomictab.get(fn));
-         if (state.DSM) {
-           temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
-         }
+         temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>)temptab.get(fn).clone());
          fgcn.addNext(fn.getNext(0));
          fn.setNext(0, fgcn);
        }
index eb35562568b0cbbca427ccdb7add1d3a86e769b7..7c9d5fd13b09cea3c50fe60c762404bd02d29ff0 100644 (file)
@@ -344,7 +344,7 @@ public class LocalityAnalysis {
        break;
 
       case FKind.FlatCall:
-       processCallNodeSTM(lb, (FlatCall)fn, isAtomic(atomictable, fn), currtable);
+       processCallNodeSTM(lb, (FlatCall)fn, isAtomic(atomictable, fn), currtable, temptable.get(fn));
        break;
 
       case FKind.FlatNew:
@@ -402,6 +402,7 @@ public class LocalityAnalysis {
       default:
        throw new Error("In finding fn.kind()= " + fn.kind());
       }
+      
       Hashtable<TempDescriptor,Integer> oldtable=temptable.get(fn);
       if (oldtable==null||!oldtable.equals(currtable)) {
        // Update table for this node
@@ -420,7 +421,7 @@ public class LocalityAnalysis {
       currtable.put(fn.getDst(), NORMAL);
   }
 
-  void processCallNodeSTM(LocalityBinding currlb, FlatCall fc, boolean isatomic, Hashtable<TempDescriptor, Integer> currtable) {
+  void processCallNodeSTM(LocalityBinding currlb, FlatCall fc, boolean isatomic, Hashtable<TempDescriptor, Integer> currtable, Hashtable<TempDescriptor, Integer> oldtable) {
     MethodDescriptor nodemd=fc.getMethod();
     Set methodset=null;
     Set runmethodset=null;
@@ -452,6 +453,12 @@ public class LocalityAnalysis {
     }
 
     Integer currreturnval=STMEITHER;     //Start off with the either value
+    if (oldtable!=null&&fc.getReturnTemp()!=null&&
+       oldtable.get(fc.getReturnTemp())!=null) {
+      //ensure termination
+      currreturnval=mergestm(currreturnval, oldtable.get(fc.getReturnTemp()));
+    }
+
     for(Iterator methodit=methodset.iterator(); methodit.hasNext();) {
       MethodDescriptor md=(MethodDescriptor) methodit.next();
 
index 1eb389dc665e12353825e330bc04ddc6d41db1eb..a946f6177d83a3957491da067e639f5b6e8d62f4 100644 (file)
@@ -223,7 +223,7 @@ public class LeeRouter {
     // start transaction
     boolean done = false;
     //synchronized(gridLock) {
-      done = connect(q.x1, q.y1, q.x2, q.y2, q.nn, tempg, grid);
+    done = connect(q.x1, q.y1, q.x2, q.y2, q.nn, tempg, grid);
       if(DEBUG && done) {
         debugQueue.next = debugQueue.enQueue(q);
       }
@@ -557,6 +557,7 @@ public class LeeRouter {
     // Taking the copy is not really a computational(time) overhead because
     // it avoids the grid 'reset' phase
     // needed if we do the expansion in place.
+      //int [][][]tempg=new int[GRID_SIZE][GRID_SIZE][2];
     for (int x = 0; x < GRID_SIZE; x++) {
       for (int y = 0; y < GRID_SIZE; y++) {
         for (int z = 0; z < 2; z++)
@@ -626,7 +627,7 @@ public class LeeRouter {
     //TODO remove after debugging
     //Large Grid size
     System.out.println("Starting main.......\n");
-    LeeRouter lr = new LeeRouter(filename, false, true, false);
+    LeeRouter lr = new LeeRouter(filename, false, false, false);
     //Small grid size
     //LeeRouter lr = new LeeRouter(filename, true, true, false);
 
index 6ae1d0cb1c36dedbfbe4b55d82ff6b4cb88a9c03..96d6e0e8769a7da972bf60f6dedfbc3ee3a879c0 100644 (file)
@@ -49,7 +49,7 @@ public class LeeThread extends Thread {
   LeeRouter lt;
   WorkQueue t;
   boolean done;
-  int[][][] tempg;
+  //  int[][][] tempg;
 
   /*
   protected static ThreadLocal<ThreadState> _threadState = new ThreadLocal<ThreadState>() {
@@ -72,12 +72,12 @@ public class LeeThread extends Thread {
     totalLaidTracks=0;
     myLaidTracks=0;
     done = true;
-
     this.lt = lt;
-    tempg = new int[lt.GRID_SIZE][lt.GRID_SIZE][2]; // Lee 2D Grid copy
   }
 
   public void run() {
+    int [][][] tempg = scratch new int[lt.GRID_SIZE][lt.GRID_SIZE][2]; // Lee 2D Grid copy
+
     while (!finished && !stop) {
       if(sampleNow) {
         //collectMyStatistics();
@@ -85,7 +85,7 @@ public class LeeThread extends Thread {
         sampleNow = false;
       }
       if(done) {
-        atomic {
+       atomic {
           t = lt.getNextTrack();
           done = false;
         }
@@ -97,9 +97,9 @@ public class LeeThread extends Thread {
         //collectStatistics(_threadState.get());
         break;
       } else {
-        atomic {
+         atomic {
           //System.out.println("Laying track "+t.nn);
-          lt.layNextTrack(t, tempg);
+             lt.layNextTrack(t, tempg);
           done = true;
         }
         //updateStatistics();
index a888e0ba5b9234444c6a5ff3cb1595e232949b6a..670e5c9fe2557890eca29ff89f7739570593a6c2 100644 (file)
@@ -5,7 +5,7 @@ SRC=${MAINCLASS}.java \
        GridCell.java \
        LeeThread.java \
        WorkQueue.java 
-FLAGS=-singleTM -optimize -mainclass ${MAINCLASS} -joptimize -debug -garbagestats -transstats
+FLAGS=-mainclass ${MAINCLASS} -joptimize -debug -singleTM -optimize -dcopts -abcclose -transstats -profile
 default:
        ../../../buildscript ${FLAGS} -o ${MAINCLASS} ${SRC}
 
index 0be64830cb6f7f6ee841fddf27cecb8ffa9dd65c..91398dc4fb34f056a000b6a2a1b59e5f7e3fbb83 100644 (file)
@@ -2195,7 +2195,8 @@ public class BuildCode {
 
       output.println(dst+"="+ src +"->"+field+ ";");
       if (ffn.getField().getType().isPtr()&&locality.getAtomic(lb).get(ffn).intValue()>0&&
-         ((dc==null)||dc.getNeedTrans(lb, ffn))) {
+         ((dc==null)||dc.getNeedTrans(lb, ffn))&&
+         locality.getNodePreTempInfo(lb, ffn).get(ffn.getSrc())!=LocalityAnalysis.SCRATCH) {
        output.println("TRANSREAD("+dst+", "+dst+");");
       }
     } else if (state.DSM) {
@@ -2263,14 +2264,17 @@ public class BuildCode {
       String dst=generateTemp(fm,fsfn.getDst(),lb);
       if (srcptr&&!fsfn.getSrc().getType().isNull()) {
        output.println("{");
-       if ((dc==null)||dc.getNeedSrcTrans(lb, fsfn)) {
+       if ((dc==null)||dc.getNeedSrcTrans(lb, fsfn)&&
+         locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getSrc())!=LocalityAnalysis.SCRATCH) {
          output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);");
        } else {
          output.println("INTPTR srcoid=(INTPTR)"+src+";");
        }
       }
-      if (wb.needBarrier(fsfn))
+      if (wb.needBarrier(fsfn)&&
+         locality.getNodePreTempInfo(lb, fsfn).get(fsfn.getDst())!=LocalityAnalysis.SCRATCH) {
        output.println("*((unsigned int *)&("+dst+"->___objstatus___))|=DIRTY;");
+      }
       if (srcptr&!fsfn.getSrc().getType().isNull()) {
        output.println("*((unsigned INTPTR *)&("+dst+"->"+ fsfn.getField().getSafeSymbol()+"))=srcoid;");
        output.println("}");
@@ -2362,7 +2366,8 @@ public class BuildCode {
       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&&
-         ((dc==null)||dc.getNeedTrans(lb, fen))) {
+         ((dc==null)||dc.getNeedTrans(lb, fen))&&
+         locality.getNodePreTempInfo(lb, fen).get(fen.getSrc())!=LocalityAnalysis.SCRATCH) {
        output.println("TRANSREAD("+dst+", "+dst+");");
       }
     } else if (state.DSM) {
@@ -2412,12 +2417,15 @@ public class BuildCode {
 
     if (state.SINGLETM && locality.getAtomic(lb).get(fsen).intValue()>0) {
       //Transaction set element case
-      if (wb.needBarrier(fsen))
+      if (wb.needBarrier(fsen)&&
+           locality.getNodePreTempInfo(lb, fsen).get(fsen.getDst())!=LocalityAnalysis.SCRATCH) {
        output.println("*((unsigned int *)&("+generateTemp(fm,fsen.getDst(),lb)+"->___objstatus___))|=DIRTY;");
+      }
       if (fsen.getSrc().getType().isPtr()&&!fsen.getSrc().getType().isNull()) {
        output.println("{");
        String src=generateTemp(fm, fsen.getSrc(), lb);
-       if ((dc==null)||dc.getNeedSrcTrans(lb, fsen)) {
+       if ((dc==null)||dc.getNeedSrcTrans(lb, fsen)&&
+           locality.getNodePreTempInfo(lb, fsen).get(fsen.getSrc())!=LocalityAnalysis.SCRATCH) {
          output.println("INTPTR srcoid=("+src+"!=NULL?((INTPTR)"+src+"->"+oidstr+"):0);");
        } else {
          output.println("INTPTR srcoid=(INTPTR)"+src+";");
index 5293f865966e5832f565bff97c965f27a70bfb17..f57330cf9df7e5e665c00d2e504899e9ecbf38d0 100644 (file)
@@ -402,7 +402,8 @@ public class BuildIR {
       TypeDescriptor td=parseTypeDescriptor(pn);
       
       Vector args=parseArgumentList(pn);
-      boolean isglobal=pn.getChild("global")!=null;
+      boolean isglobal=pn.getChild("global")!=null||
+       pn.getChild("scratch")!=null;
       String disjointId=null;
       if( pn.getChild("disjoint") != null) {
        disjointId = pn.getChild("disjoint").getTerminal();
@@ -425,7 +426,8 @@ public class BuildIR {
       return con;
     } else if (isNode(pn,"createarray")) {
       //System.out.println(pn.PPrint(3,true));
-      boolean isglobal=pn.getChild("global")!=null;
+      boolean isglobal=pn.getChild("global")!=null||
+       pn.getChild("scratch")!=null;
       String disjointId=null;
       if( pn.getChild("disjoint") != null) {
        disjointId = pn.getChild("disjoint").getTerminal();
index 05e06662bac58b02d0d85a9c0dc82f63974f63b1..b661593789fea8d497b9d2d71ab0715fc8abe82f 100644 (file)
@@ -79,6 +79,7 @@ class Keyword extends Token {
     //Keywords for transactions
     key_table.put("atomic", new Integer(Sym.ATOMIC));
     key_table.put("global", new Integer(Sym.GLOBAL));
+    key_table.put("scratch", new Integer(Sym.SCRATCH));
     //Keywords for hacking prefetch calls in java
     key_table.put("getoffset", new Integer(Sym.GETOFFSET));
     //Keywords for disjointness in Java
index 7bcc6450922331dffc6a8ead9b07758e9e4f985f..7b79531bb4858214227633e54468b7bc5873a57e 100644 (file)
@@ -268,7 +268,7 @@ public class Lexer {
     "isavailable",
     "long",
     "native", "new", "optional", "package", "private", "protected", "public",
-    "return", "sese", "short", "static", "strictfp", "super", "switch", "synchronized",
+    "return", "scratch", "sese", "short", "static", "strictfp", "super", "switch", "synchronized",
     "tag", "task", "taskexit", //keywords for failure aware computation
     "this", "throw", "throws", "transient", "try", "void",
     "volatile", "while"
index 4ddaac5629c73ef8ec6cc7d3b3dca0f0363aa7dd..bf5141bd5ebfc0d78ac458a94e61defac5d7fb00 100644 (file)
@@ -256,6 +256,7 @@ non terminal ParseNode tag_change;
 //distributed transaction keywords
 terminal ATOMIC;
 terminal GLOBAL;
+terminal SCRATCH;
 terminal GETOFFSET;
 non terminal ParseNode atomic_statement;
 non terminal ParseNode getoffset_expression;
@@ -987,7 +988,8 @@ constructor_declaration ::=
                pn.addChild("body").addChild(body);
                RESULT=pn;
        :}
-       ;
+;
+
 constructor_declarator ::=
                simple_name:name LPAREN formal_parameter_list_opt:fplo RPAREN {: 
                ParseNode pn=new ParseNode("constructor_declarator");
@@ -1447,6 +1449,14 @@ class_instance_creation_expression ::=
                pn.addChild("global");
                RESULT=pn;
        :}
+       | SCRATCH NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
+               ParseNode pn=new ParseNode("createobject");
+               pn.addChild(type);
+               pn.addChild(args);
+               pn.addChild(feo);
+               pn.addChild("scratch");
+               RESULT=pn;
+       :}
        // Objects we want to track in disjointness analysis
        | DISJOINT IDENTIFIER:id NEW class_or_interface_type:type LPAREN argument_list_opt:args RPAREN flag_list_opt:feo {: 
                ParseNode pn=new ParseNode("createobject");
@@ -1545,6 +1555,14 @@ array_creation_uninit ::=
                pn.addChild("global");
                RESULT=pn;
                :}
+       |       SCRATCH NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               pn.addChild("scratch");
+               RESULT=pn;
+               :}
        |       DISJOINT IDENTIFIER:id NEW primitive_type:type dim_exprs:dimexpr dims_opt:dims {: 
                ParseNode pn=new ParseNode("createarray");
                pn.addChild(type);
@@ -1561,6 +1579,14 @@ array_creation_uninit ::=
                pn.addChild("global");
                RESULT=pn;
                :}
+       |       SCRATCH NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
+               ParseNode pn=new ParseNode("createarray");
+               pn.addChild(type);
+               pn.addChild(dimexpr);
+               pn.addChild("dims_opt").setLiteral(dims);
+               pn.addChild("scratch");
+               RESULT=pn;
+               :}
        |       DISJOINT IDENTIFIER:id NEW class_or_interface_type:type dim_exprs:dimexpr dims_opt:dims {: 
                ParseNode pn=new ParseNode("createarray");
                pn.addChild(type);
index 9c440563690d69607f8c87a32321fa44c33d241d..5289c4ed6fa8c393abc605f5f60cdd1b179548f3 100644 (file)
@@ -22,7 +22,7 @@
 
 #define NUMPTRS 100
 
-#define INITIALHEAPSIZE 64*1024*1024
+#define INITIALHEAPSIZE 128*1024*1024
 #define GCPOINT(x) ((int)((x)*0.95))
 /* This define takes in how full the heap is initially and returns a new heap size to use */
 #define HEAPSIZE(x,y) ((int)(x+y))*2
index a7790dfc1c7b3863da77629773009d26f59512f6..11a7d762e2660fa5046415ea8428c8b767234c91 100644 (file)
@@ -125,7 +125,7 @@ void initthread(struct ___Thread___ * ___this___) {
   t_cache = objstrCreate(1048576);
   t_reserve=NULL;
   t_chashCreate(CHASH_SIZE, CLOADFACTOR);
- ___Thread____NN____staticStart____L___Thread___((struct ___Thread____NN____staticStart____L___Thread____params *)p);
+ ___Thread____NNR____staticStart____L___Thread___((struct ___Thread____NNR____staticStart____L___Thread____params *)p);
  objstrDelete(t_cache);
  objstrDelete(t_reserve);
  t_chashDelete();