From faaa5bc27e9856de697946c0b14bdd3f23bc5514 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 14 Apr 2009 23:05:36 +0000 Subject: [PATCH] add support for scratch memory --- .../Locality/GenerateConversions.java | 17 ++++++----- .../Analysis/Locality/LocalityAnalysis.java | 11 ++++++-- .../SingleTM/LeeRouting/LeeRouter.java | 5 ++-- .../SingleTM/LeeRouting/LeeThread.java | 12 ++++---- .../Benchmarks/SingleTM/LeeRouting/makefile | 2 +- Robust/src/IR/Flat/BuildCode.java | 20 +++++++++---- Robust/src/IR/Tree/BuildIR.java | 6 ++-- Robust/src/Lex/Keyword.java | 1 + Robust/src/Lex/Lexer.java | 2 +- Robust/src/Parse/java14.cup | 28 ++++++++++++++++++- Robust/src/Runtime/garbage.c | 2 +- Robust/src/Runtime/thread.c | 2 +- 12 files changed, 76 insertions(+), 32 deletions(-) diff --git a/Robust/src/Analysis/Locality/GenerateConversions.java b/Robust/src/Analysis/Locality/GenerateConversions.java index 4e9d3d67..41bcc0e1 100644 --- a/Robust/src/Analysis/Locality/GenerateConversions.java +++ b/Robust/src/Analysis/Locality/GenerateConversions.java @@ -49,7 +49,7 @@ public class GenerateConversions { toprocess.remove(fn); boolean isatomic=atomictab.get(fn).intValue()>0; - Hashtable nodetemptab=state.DSM?temptab.get(fn):null; + Hashtable nodetemptab=temptab.get(fn); List reads=Arrays.asList(fn.readsTemps()); List writes=Arrays.asList(fn.writesTemps()); @@ -112,7 +112,8 @@ public class GenerateConversions { for(Iterator 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)temptab.get(fn).clone()); + temptab.put(fgcn, (Hashtable)temptab.get(fn).clone()); FlatNode[] prevarray=new FlatNode[fn.numPrev()]; for(int i=0; i pretemptab=locality.getNodePreTempInfo(lb, fn); if (state.SINGLETM) { TempDescriptor [] readtemps=fn.readsTemps(); for(int i=0; i pretemptab=locality.getNodePreTempInfo(lb, fn); TempDescriptor [] readtemps=fn.readsTemps(); for(int i=0; i 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)temptab.get(fn).clone()); - } + temptab.put(fgcn, (Hashtable)temptab.get(fn).clone()); fgcn.addNext(fn.getNext(0)); fn.setNext(0, fgcn); } diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index eb355625..7c9d5fd1 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -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 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 currtable) { + void processCallNodeSTM(LocalityBinding currlb, FlatCall fc, boolean isatomic, Hashtable currtable, Hashtable 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(); diff --git a/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java b/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java index 1eb389dc..a946f617 100644 --- a/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java +++ b/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeRouter.java @@ -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); diff --git a/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java b/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java index 6ae1d0cb..96d6e0e8 100644 --- a/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java +++ b/Robust/src/Benchmarks/SingleTM/LeeRouting/LeeThread.java @@ -49,7 +49,7 @@ public class LeeThread extends Thread { LeeRouter lt; WorkQueue t; boolean done; - int[][][] tempg; + // int[][][] tempg; /* protected static ThreadLocal _threadState = new ThreadLocal() { @@ -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(); diff --git a/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile b/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile index a888e0ba..670e5c9f 100644 --- a/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile +++ b/Robust/src/Benchmarks/SingleTM/LeeRouting/makefile @@ -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} diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 0be64830..91398dc4 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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+";"); diff --git a/Robust/src/IR/Tree/BuildIR.java b/Robust/src/IR/Tree/BuildIR.java index 5293f865..f57330cf 100644 --- a/Robust/src/IR/Tree/BuildIR.java +++ b/Robust/src/IR/Tree/BuildIR.java @@ -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(); diff --git a/Robust/src/Lex/Keyword.java b/Robust/src/Lex/Keyword.java index 05e06662..b6615937 100644 --- a/Robust/src/Lex/Keyword.java +++ b/Robust/src/Lex/Keyword.java @@ -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 diff --git a/Robust/src/Lex/Lexer.java b/Robust/src/Lex/Lexer.java index 7bcc6450..7b79531b 100644 --- a/Robust/src/Lex/Lexer.java +++ b/Robust/src/Lex/Lexer.java @@ -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" diff --git a/Robust/src/Parse/java14.cup b/Robust/src/Parse/java14.cup index 4ddaac56..bf5141bd 100644 --- a/Robust/src/Parse/java14.cup +++ b/Robust/src/Parse/java14.cup @@ -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); diff --git a/Robust/src/Runtime/garbage.c b/Robust/src/Runtime/garbage.c index 9c440563..5289c4ed 100644 --- a/Robust/src/Runtime/garbage.c +++ b/Robust/src/Runtime/garbage.c @@ -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 diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index a7790dfc..11a7d762 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -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(); -- 2.34.1