From: jjenista Date: Tue, 28 Jul 2009 23:12:58 +0000 (+0000) Subject: newly realized mlp successfully issues and runs root SESE as a work unit X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=24aff972020b453e946c45c0a3fef8a8e3f66f31;p=IRC.git newly realized mlp successfully issues and runs root SESE as a work unit --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index cca23e91..b658a2e5 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -75,7 +75,10 @@ public class MLPAnalysis { FlatMethod fmMain = state.getMethodFlat( tu.getMain() ); - rootSESE = (FlatSESEEnterNode) fmMain.getNext(0); + rootSESE = (FlatSESEEnterNode) fmMain.getNext(0); + rootSESE.setfmEnclosing( fmMain ); + rootSESE.setmdEnclosing( fmMain.getMethod() ); + rootSESE.setcdEnclosing( fmMain.getMethod().getClassDesc() ); // 1st pass @@ -140,11 +143,11 @@ public class MLPAnalysis { if( state.MLPDEBUG ) { System.out.println( "" ); //System.out.println( "\nSESE Hierarchy\n--------------\n" ); printSESEHierarchy(); - //System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness(); - System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) ); - System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) ); - System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) ); - System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); + System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness(); + //System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) ); + //System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) ); + //System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) ); + //System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 49a38393..aa8501a3 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -181,6 +181,7 @@ public class BuildCode { if (state.MLP) { outmethodheader.println("#include "); outmethodheader.println("#include "); + outmethodheader.println("#include "); outmethodheader.println("#include \"mlp_runtime.h\""); } @@ -215,6 +216,16 @@ public class BuildCode { outputTaskTypes(outtask); } + if( state.MLP ) { + // have to initialize some SESE compiler data before + // analyzing normal methods, which must happen before + // generating SESE internal code + for(Iterator seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) { + FlatSESEEnterNode fsen = seseit.next(); + initializeSESE( fsen ); + } + } + /* Build the actual methods */ outputMethods(outmethod); @@ -272,6 +283,11 @@ public class BuildCode { private void outputMainMethod(PrintWriter outmethod) { outmethod.println("int main(int argc, const char *argv[]) {"); outmethod.println(" int i;"); + + if (state.MLP) { + outmethod.println(" workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );"); + } + if (state.DSM) { outmethod.println("#ifdef TRANSSTATS \n"); outmethod.println("handle();\n"); @@ -373,8 +389,6 @@ public class BuildCode { outmethod.println("pthread_exit(NULL);"); if (state.MLP) { - outmethod.println(" workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );"); - // issue root SESE outmethod.println(" workScheduleBegin();"); } @@ -1649,13 +1663,8 @@ public class BuildCode { } - protected void generateMethodSESE(FlatSESEEnterNode fsen, - LocalityBinding lb, - PrintWriter outputStructs, - PrintWriter outputMethHead, - PrintWriter outputMethods - ) { - + protected void initializeSESE( FlatSESEEnterNode fsen ) { + FlatMethod fm = fsen.getfmEnclosing(); MethodDescriptor md = fm.getMethod(); ClassDescriptor cn = md.getClassDesc(); @@ -1674,29 +1683,23 @@ public class BuildCode { fsen.setfmBogus( fmBogus ); fsen.setmdBogus( mdBogus ); + Set inSetAndOutSet = new HashSet(); + inSetAndOutSet.addAll( fsen.getInVarSet() ); + inSetAndOutSet.addAll( fsen.getOutVarSet() ); // Build paramsobj for bogus method descriptor ParamsObject objectparams = new ParamsObject( mdBogus, tag++ ); paramstable.put( mdBogus, objectparams ); - Set inSetAndOutSet = new HashSet(); - inSetAndOutSet.addAll( fsen.getInVarSet() ); - inSetAndOutSet.addAll( fsen.getOutVarSet() ); - - Set inSetAndOutSetPrims = new HashSet(); - Iterator itr = inSetAndOutSet.iterator(); while( itr.hasNext() ) { TempDescriptor temp = itr.next(); TypeDescriptor type = temp.getType(); if( type.isPtr() ) { objectparams.addPtr( temp ); - } else { - inSetAndOutSetPrims.add( temp ); } } - - + // Build normal temp object for bogus method descriptor TempObject objecttemps = new TempObject( objectparams, mdBogus, tag++ ); tempstable.put( mdBogus, objecttemps ); @@ -1713,6 +1716,34 @@ public class BuildCode { objecttemps.addPrim(temp); } } + } + + protected void generateMethodSESE(FlatSESEEnterNode fsen, + LocalityBinding lb, + PrintWriter outputStructs, + PrintWriter outputMethHead, + PrintWriter outputMethods + ) { + + ParamsObject objectparams = (ParamsObject) paramstable.get( fsen.getmdBogus() ); + + Set inSetAndOutSet = new HashSet(); + inSetAndOutSet.addAll( fsen.getInVarSet() ); + inSetAndOutSet.addAll( fsen.getOutVarSet() ); + + Set inSetAndOutSetPrims = new HashSet(); + + Iterator itr = inSetAndOutSet.iterator(); + while( itr.hasNext() ) { + TempDescriptor temp = itr.next(); + TypeDescriptor type = temp.getType(); + if( !type.isPtr() ) { + inSetAndOutSetPrims.add( temp ); + } + } + + TempObject objecttemps = (TempObject) tempstable.get( fsen.getmdBogus() ); + // generate the SESE record structure outputStructs.println(fsen.getSESErecordName()+" {"); @@ -1724,6 +1755,21 @@ public class BuildCode { outputStructs.println(" INTPTR size;"); outputStructs.println(" void * next;"); + // in-set source pointers + Iterator itrInSet = fsen.getInVarSet().iterator(); + while( itrInSet.hasNext() ) { + TempDescriptor temp = itrInSet.next(); + outputStructs.println(" INTPTR "+temp.getSafeSymbol()+"__srcAddr_;"); + } + + // all in and out set primitives + Iterator itrPrims = inSetAndOutSetPrims.iterator(); + while( itrPrims.hasNext() ) { + TempDescriptor temp = itrPrims.next(); + TypeDescriptor type = temp.getType(); + outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";"); + } + for(int i=0; i itrPrims = inSetAndOutSetPrims.iterator(); - while( itrPrims.hasNext() ) { - TempDescriptor temp = itrPrims.next(); - TypeDescriptor type = temp.getType(); - outputStructs.println(" "+temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol()+";"); - } - outputStructs.println("};\n"); // generate locals structure - outputStructs.println("struct "+cn.getSafeSymbol()+mdBogus.getSafeSymbol()+"_"+mdBogus.getSafeMethodDescriptor()+"_locals {"); + outputStructs.println("struct "+fsen.getcdEnclosing().getSafeSymbol()+fsen.getmdBogus().getSafeSymbol()+"_"+fsen.getmdBogus().getSafeMethodDescriptor()+"_locals {"); outputStructs.println(" INTPTR size;"); outputStructs.println(" void * next;"); for(int i=0; isize)"); + output.print("(void*) &("+paramsprefix+"->size)"); for(int j=0; j itrInSet = fsen.getInVarSet().iterator(); + while( itrInSet.hasNext() ) { + TempDescriptor temp = itrInSet.next(); + TypeDescriptor type = temp.getType(); + + String sizeofStr = ""; + if( type.isPtr() ) { + sizeofStr = "struct "; + } + sizeofStr += type.getSafeSymbol(); + + output.println(" memcpy( "+ + "(void*) &("+paramsprefix+"->"+temp.getSafeSymbol()+"), "+ // to + "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from + " sizeof( "+sizeofStr+" ) );"); // size + + // make a deep copy of objects + //if( type.isPtr() ) { + // deep copy + //} else { + // shallow copy + //} + } + // Check to see if we need to do a GC if this is a // multi-threaded program... if (GENERATEPRECISEGC) { @@ -1847,7 +1914,6 @@ public class BuildCode { HashSet exitset=new HashSet(); exitset.add(seseExit); generateCode(fsen.getNext(0), fm, null, exitset, output, true); - output.println("}\n\n"); } @@ -1898,19 +1964,6 @@ public class BuildCode { Set stopset, PrintWriter output, boolean firstpass) { - // for any method, allocate temps to use when - // issuing a new SESE sometime during the execution - // of that method, whether it be a user-defined method - // or a method representing the body of an SESE - // TODO: only do this if we know the method actually - // contains an SESE issue, not currently an annotation - if( state.MLP ) { - /* - output.println(" SESErecord* tempSESE;"); - output.println(" invokeSESEargs* tempSESEargs;"); - */ - } - /* Assign labels to FlatNode's if necessary.*/ Hashtable nodetolabel=assignLabels(first, stopset); @@ -2610,18 +2663,26 @@ public class BuildCode { if( !state.MLP ) { // SESE nodes can be parsed for normal compilation, just skip over them return; + } + output.println(" {"); + output.println(" "+fsen.getSESErecordName()+"* seseToIssue = ("+ + fsen.getSESErecordName()+"*) mlpAllocSESErecord( sizeof( "+ + fsen.getSESErecordName()+" ) );"); + output.println(" seseToIssue->classID = "+fsen.getIdentifier()+";"); + + // give pointers to in-set variables, when this SESE is ready to + // execute it should copy values from the pointers because they + // will be guaranteed to be ready for consumption then + Iterator itr = fsen.getInVarSet().iterator(); + while( itr.hasNext() ) { + TempDescriptor temp = itr.next(); + output.println(" seseToIssue->"+temp.getSafeSymbol()+ + "__srcAddr_ = (INTPTR) &("+paramsprefix+"->"+ + temp.getSafeSymbol()+");"); } - output.println( " {" ); - - output.println( " "); - output.println( " "); - output.println( " "); - output.println( " "); - - output.println( " "); - - output.println( " }" ); + output.println(" workScheduleSubmit( (void*) seseToIssue );"); + output.println(" }"); } public void generateFlatSESEExitNode(FlatMethod fm, LocalityBinding lb, FlatSESEExitNode fsen, PrintWriter output) { @@ -3308,9 +3369,11 @@ public class BuildCode { } else output.print(task.getSafeSymbol()+"("); + /* if (addSESErecord) { output.print("SESErecord* currentSESE, "); } + */ boolean printcomma=false; if (GENERATEPRECISEGC) { diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 6b2e1518..a7717360 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -208,6 +208,9 @@ public class FlatSESEEnterNode extends FlatNode { public MethodDescriptor getmdBogus() { return mdBogus; } public String getSESEmethodName() { + assert cdEnclosing != null; + assert mdBogus != null; + return cdEnclosing.getSafeSymbol()+ mdBogus.getSafeSymbol()+ @@ -216,6 +219,9 @@ public class FlatSESEEnterNode extends FlatNode { } public String getSESErecordName() { + assert cdEnclosing != null; + assert mdBogus != null; + return "struct "+ cdEnclosing.getSafeSymbol()+ diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index a18b4fea..25f5b9f8 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -14,36 +14,34 @@ #define TRUE 1 -/* -SESErecord* mlpCreateSESErecord( int classID, - void* inSetOutSetObjs, - void* inSetOutSetPrims - ) { - - SESErecord* newrec = RUNMALLOC( sizeof( SESErecord ) ); - newrec->classID = classID; - newrec->inSetOutSetObjs = inSetOutSetObjs; - newrec->inSetOutSetPrims = inSetOutSetPrims; +void* mlpAllocSESErecord( int size ) { + void* newrec = RUNMALLOC( size ); + + /* + SESErecord* commonView = (SESErecord*) newrec; + commonView->classID = classID; pthread_mutex_init( &(newrec->lock), NULL ); newrec->forwardList = createQueue(); newrec->doneExecuting = FALSE; + */ return newrec; } -void mlpDestroySESErecord( SESErecord* sese ) { +void mlpFreeSESErecord( void* seseRecord ) { - pthread_mutex_destroy( &(sese->lock) ); - freeQueue( sese->forwardList ); + /* + SESErecord* commonView = (SESErecord*) seseRecord; + pthread_mutex_destroy( &(commonView->lock) ); + freeQueue( commonView->forwardList ); + */ - RUNFREE( sese->inSetOutSetObjs ); - RUNFREE( sese->inSetOutSetPrims ); - RUNFREE( sese ); + RUNFREE( seseRecord ); } -*/ + /* struct rootSESEinSetObjs { char** argv; }; diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 5a505ce3..53c90e1c 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -6,25 +6,20 @@ #include "Queue.h" #include "psemaphore.h" -/* + // forward delcarations -struct SESErecord_t; +//struct SESErecord_t; +// note that this record is never used other than +// to cast a customized record and have easy access +// the common fields listed here typedef struct SESErecord_t { + // the identifier for the class of sese's that // are instances of one particular static code block int classID; - // This field is a structure of in-set and out-set - // objects with the following layout: - // [INTPTR numPtrs][void* next][ptr0][ptr1]... - void* inSetOutSetObjs; - - // This field is a structure of primitives for - // the in-set and out-set - void* inSetOutSetPrims; - // the lock guards the following data SESE's // use to coordinate with one another pthread_mutex_t lock; @@ -32,7 +27,7 @@ typedef struct SESErecord_t { int doneExecuting; } SESErecord; -*/ + /* typedef struct SESEvarSrc_t { @@ -41,16 +36,11 @@ typedef struct SESEvarSrc_t { } SESEvarSrc; */ -/* -// simple mechanical allocation and deallocation -// of SESE records -SESErecord* mlpCreateSESErecord( int classID, - void* inSetOutSetObjs, - void* inSetOutSetPrims - ); - -void mlpDestroySESErecord( SESErecord* sese ); -*/ + +// simple mechanical allocation and +// deallocation of SESE records +void* mlpCreateSESErecord( int classID, int size ); +void mlpDestroySESErecord( void* seseRecord ); // main library functions diff --git a/Robust/src/Tests/mlp/tinyTest/makefile b/Robust/src/Tests/mlp/tinyTest/makefile index 2633b45b..dc89f190 100644 --- a/Robust/src/Tests/mlp/tinyTest/makefile +++ b/Robust/src/Tests/mlp/tinyTest/makefile @@ -4,7 +4,7 @@ SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript -USEMLP= -mlp 1 2 # -mlpdebug # use to turn mlp on and off and make sure rest of build not broken +USEMLP= -mlp 1 2 -mlpdebug # use to turn mlp on and off and make sure rest of build not broken BSFLAGS= $(USEMLP) -nooptimize -debug -garbagestats -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt all: $(PROGRAM).bin diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index a6b6f2f1..62d9c34a 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -7,22 +7,23 @@ public class Test { public static void main( String args[] ) { - int x = 1; - int y = 1; + int x = Integer.parseInt( args[0] ); + int y = Integer.parseInt( args[1] ); //Foo f; - + /* sese fi { //if( true ) { - x = y + 2; - y = 3; - + System.out.println( "fi: x="+x+", y="+y ); + x = y + 2; + y = 3; + //f = new Foo(); //} } - + */ // just for testing root's ability to // realize a single exit after all returns