newly realized mlp successfully issues and runs root SESE as a work unit
authorjjenista <jjenista>
Tue, 28 Jul 2009 23:12:58 +0000 (23:12 +0000)
committerjjenista <jjenista>
Tue, 28 Jul 2009 23:12:58 +0000 (23:12 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/FlatSESEEnterNode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h
Robust/src/Tests/mlp/tinyTest/makefile
Robust/src/Tests/mlp/tinyTest/test.java

index cca23e91f977fcda81c3bd793ec68e5625db996b..b658a2e5ad2d7623bf65a009064f38ef253853ba 100644 (file)
@@ -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 ) );
     }
 
 
index 49a38393794b46a49acbdc48f040bd6aaae70c70..aa8501a33fd8aed70053074ad7a88c9c12928a4e 100644 (file)
@@ -181,6 +181,7 @@ public class BuildCode {
     if (state.MLP) {
       outmethodheader.println("#include <stdlib.h>");
       outmethodheader.println("#include <stdio.h>");
+      outmethodheader.println("#include <string.h>");
       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<FlatSESEEnterNode> 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<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+    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<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
-    inSetAndOutSet.addAll( fsen.getInVarSet() );
-    inSetAndOutSet.addAll( fsen.getOutVarSet() );
-
-    Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
-
     Iterator<TempDescriptor> 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<TempDescriptor> inSetAndOutSet = new HashSet<TempDescriptor>();
+    inSetAndOutSet.addAll( fsen.getInVarSet() );
+    inSetAndOutSet.addAll( fsen.getOutVarSet() );
+
+    Set<TempDescriptor> inSetAndOutSetPrims = new HashSet<TempDescriptor>();
+
+    Iterator<TempDescriptor> 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<TempDescriptor> itrInSet = fsen.getInVarSet().iterator();
+    while( itrInSet.hasNext() ) {
+      TempDescriptor temp = itrInSet.next();
+      outputStructs.println("  INTPTR "+temp.getSafeSymbol()+"__srcAddr_;");
+    }    
+
+    // all in and out set primitives
+    Iterator<TempDescriptor> 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<objectparams.numPointers(); i++) {
       TempDescriptor temp=objectparams.getPointer(i);
       if (temp.getType().isNull())
@@ -1732,18 +1778,10 @@ public class BuildCode {
         outputStructs.println("  struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
     }
     
-    // then other SESE runtime data
-    Iterator<TempDescriptor> 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; i<objecttemps.numPointers(); i++) {
@@ -1759,7 +1797,7 @@ public class BuildCode {
     // write method declaration to header file
     outputMethHead.print("void ");
     outputMethHead.print(fsen.getSESEmethodName()+"(");
-    outputMethHead.print(fsen.getSESErecordName()+"* currentSESE ");
+    outputMethHead.print(fsen.getSESErecordName()+"* "+paramsprefix);
 
     /*
     boolean printcomma=false;
@@ -1784,7 +1822,11 @@ public class BuildCode {
 
     outputMethHead.println(");\n");
 
-    generateFlatMethodSESE(fmBogus, cn, fsen, fsen.getFlatExit(), outputMethods);
+    generateFlatMethodSESE( fsen.getfmBogus(), 
+                           fsen.getcdEnclosing(), 
+                           fsen, 
+                           fsen.getFlatExit(), 
+                           outputMethods );
   }
 
   private void generateFlatMethodSESE(FlatMethod fm, 
@@ -1800,7 +1842,7 @@ public class BuildCode {
 
     output.print("void ");
     output.print(fsen.getSESEmethodName()+"(");
-    output.print(fsen.getSESErecordName()+"* currentSESE ");
+    output.print(fsen.getSESErecordName()+"* "+paramsprefix);
     output.println("){\n");
 
     TempObject objecttemp=(TempObject) tempstable.get(md);
@@ -1808,7 +1850,7 @@ public class BuildCode {
     if (GENERATEPRECISEGC) {
       output.print("   struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={");
       output.print(objecttemp.numPointers()+",");
-      output.print("(void*) &(currentSESE->size)");
+      output.print("(void*) &("+paramsprefix+"->size)");
       for(int j=0; j<objecttemp.numPointers(); j++)
        output.print(", NULL");
       output.println("};");
@@ -1835,6 +1877,31 @@ public class BuildCode {
     }
     */
 
+    // copy in-set into place
+    Iterator<TempDescriptor> 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<FlatNode> exitset=new HashSet<FlatNode>();
     exitset.add(seseExit);
     generateCode(fsen.getNext(0), fm, null, exitset, output, true);
-
     
     output.println("}\n\n");
   }
@@ -1898,19 +1964,6 @@ public class BuildCode {
                              Set<FlatNode> 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<FlatNode, Integer> 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<TempDescriptor> 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) {
index 6b2e1518006586b5bdd32fbf566df73f26f62d64..a77173600e21a0fb3c0d28fe2413473f29f2304f 100644 (file)
@@ -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()+
index a18b4fea70e9d1d88394e44a1eef50599e823c7c..25f5b9f88719ced7ddbfd16fa648b9acf494b597 100644 (file)
 #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; };
index 5a505ce33a7b2541782bb8aef8da70df53b72104..53c90e1c595db9a5cec2888fd4d59b78a7962567 100644 (file)
@@ -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
index 2633b45b8cba010ae3a39d7fa3d20c10cb94c16b..dc89f190d406bba15b0ec276be68019f900e312c 100644 (file)
@@ -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
index a6b6f2f169c5e03caabc578c29089f3f9ae4ed4d..62d9c34acad820c715f9350cf1225334b8bf67f1 100644 (file)
@@ -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