more work on mlp system
authorjjenista <jjenista>
Tue, 16 Jun 2009 21:47:49 +0000 (21:47 +0000)
committerjjenista <jjenista>
Tue, 16 Jun 2009 21:47:49 +0000 (21:47 +0000)
Robust/src/Analysis/MLP/CodePlan.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h
Robust/src/Tests/mlp/tinyTest/test.java

index d5df97481b825d9c7d82a2673fcae266f50d449a..ed90f2c282029b1a806c2f3f36a02f6455e6bb41 100644 (file)
@@ -10,23 +10,22 @@ import java.io.*;
 // for injecting code before and/or after a flat node
 public class CodePlan {
 
-  private FlatSESEEnterNode seseToIssue;
-
-
+  private Set<VariableSourceToken> writeToDynamicSrc;
+  
   public CodePlan() {
-    seseToIssue = null;
+    writeToDynamicSrc = null;
   }
 
-
-  public void setSESEtoIssue( FlatSESEEnterNode sese ) {
-    seseToIssue = sese;
+  public void setWriteToDynamicSrc( 
+               Set<VariableSourceToken> writeToDynamicSrc 
+                                 ) {
+    this.writeToDynamicSrc = writeToDynamicSrc;
   }
 
-  public FlatSESEEnterNode getSESEtoIssue() {
-    return seseToIssue;
+  public Set<VariableSourceToken> getWriteToDynamicSrc() {
+    return writeToDynamicSrc;
   }
 
-
   public boolean equals( Object o ) {
     if( o == null ) {
       return false;
@@ -38,30 +37,38 @@ public class CodePlan {
 
     CodePlan cp = (CodePlan) o;
 
-    boolean issueEq;
-    if( seseToIssue == null ) {
-      issueEq = (cp.seseToIssue == null);
+    boolean dynamicSetEq;
+    if( writeToDynamicSrc == null ) {
+      dynamicSetEq = (cp.writeToDynamicSrc == null);
     } else {
-      issueEq = (seseToIssue.equals( cp.seseToIssue ));
+      dynamicSetEq = (writeToDynamicSrc.equals( cp.writeToDynamicSrc ));
     }
         
-    return issueEq;
+    return dynamicSetEq;
   }
 
   public int hashCode() {
-    int issueHC = 1;
-    if( seseToIssue != null  ) {
-      issueHC = seseToIssue.hashCode();
+    int dynamicSetHC = 1;
+    if( writeToDynamicSrc != null  ) {
+      dynamicSetHC = writeToDynamicSrc.hashCode();
     }
 
-    return issueHC;
+    return dynamicSetHC;
   }
 
   public String toString() {
     String s = "";
 
-    if( seseToIssue != null ) {
-      s += "[ISSUE "+seseToIssue.getPrettyIdentifier()+"]";
+    if( writeToDynamicSrc != null ) {
+      s += "[WRITE DYN";
+
+      Iterator<VariableSourceToken> vstItr = writeToDynamicSrc.iterator();
+      while( vstItr.hasNext() ) {
+       VariableSourceToken vst = vstItr.next();
+       s += ", "+vst;
+      }
+
+      s += "]";
     }
 
     return s;
index 0df10c511d8476d4cd2806f83fa2d364be26b858..1f0dc5c70fa5ab6b0a5a3673b13f7fa5f0aa2fed 100644 (file)
@@ -26,6 +26,8 @@ import Analysis.Loops.WriteBarrier;
 import Analysis.Loops.GlobalFieldType;
 import Analysis.Locality.TypeAnalysis;
 import Analysis.MLP.MLPAnalysis;
+import Analysis.MLP.VariableSourceToken;
+import Analysis.MLP.CodePlan;
 
 public class BuildCode {
   State state;
@@ -304,17 +306,6 @@ public class BuildCode {
       outmethod.println("    ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i-1]=newstring;");
     outmethod.println("  }");
 
-    if (state.MLP) {
-      FlatSESEEnterNode rootSESE = mlpa.getRootSESE();
-      outmethod.println("  mlpInit();");
-
-      outmethod.print("  rootsese = mlpCreateSESErecord(");
-      outmethod.print(rootSESE.getIdentifier()+", 0, NULL, 0, NULL");
-      outmethod.println(");");
-
-      outmethod.println("  ");
-    }
-
     MethodDescriptor md=typeutil.getMain();
     ClassDescriptor cd=typeutil.getMainClass();
 
@@ -444,10 +435,6 @@ public class BuildCode {
       outmethod.println("#include <stdlib.h>");
       outmethod.println("#include <stdio.h>");
       outmethod.println("#include \"mlp_runtime.h\"");
-      outmethod.println("/* GET RID OF THIS LATER */");
-      outmethod.println("SESErecord*     tempSESE;");
-      outmethod.println("SESErecord*     tempParentSESE;");    
-      outmethod.println("invokeSESEargs* tempSESEargs;");
     }
 
 
@@ -1791,6 +1778,18 @@ public class BuildCode {
                               FlatSESEExitNode stop,
                               PrintWriter output) {
 
+    // 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("   SESErecord*     tempParentSESE;");    
+      output.println("   invokeSESEargs* tempSESEargs;");
+    }
+
     /* Assign labels to FlatNode's if necessary.*/
     Hashtable<FlatNode, Integer> nodetolabel=assignLabels(first, stop);
 
@@ -1923,82 +1922,84 @@ public class BuildCode {
   }
 
   protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) {
+
     switch(fn.kind()) {
+
     case FKind.FlatAtomicEnterNode:
       generateFlatAtomicEnterNode(fm, lb, (FlatAtomicEnterNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatAtomicExitNode:
       generateFlatAtomicExitNode(fm, lb, (FlatAtomicExitNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatInstanceOfNode:
       generateFlatInstanceOfNode(fm, lb, (FlatInstanceOfNode)fn, output);
-      return;
+      break;
 
     case FKind.FlatSESEEnterNode:
       generateFlatSESEEnterNode(fm, lb, (FlatSESEEnterNode)fn, output);
-      return;
+      break;
 
     case FKind.FlatSESEExitNode:
       generateFlatSESEExitNode(fm, lb, (FlatSESEExitNode)fn, output);
-      return;
+      break;
 
     case FKind.FlatGlobalConvNode:
       generateFlatGlobalConvNode(fm, lb, (FlatGlobalConvNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatTagDeclaration:
       generateFlatTagDeclaration(fm, lb, (FlatTagDeclaration) fn,output);
-      return;
+      break;
 
     case FKind.FlatCall:
       generateFlatCall(fm, lb, (FlatCall) fn,output);
-      return;
+      break;
 
     case FKind.FlatFieldNode:
       generateFlatFieldNode(fm, lb, (FlatFieldNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatElementNode:
       generateFlatElementNode(fm, lb, (FlatElementNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatSetElementNode:
       generateFlatSetElementNode(fm, lb, (FlatSetElementNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatSetFieldNode:
       generateFlatSetFieldNode(fm, lb, (FlatSetFieldNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatNew:
       generateFlatNew(fm, lb, (FlatNew) fn,output);
-      return;
+      break;
 
     case FKind.FlatOpNode:
       generateFlatOpNode(fm, lb, (FlatOpNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatCastNode:
       generateFlatCastNode(fm, lb, (FlatCastNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatLiteralNode:
       generateFlatLiteralNode(fm, lb, (FlatLiteralNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatReturnNode:
       generateFlatReturnNode(fm, lb, (FlatReturnNode) fn,output);
-      return;
+      break;
 
     case FKind.FlatNop:
       output.println("/* nop */");
-      return;
+      break;
 
     case FKind.FlatExit:
       output.println("/* exit */");
-      return;
+      break;
 
     case FKind.FlatBackEdge:
       if ((state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) {
@@ -2008,25 +2009,39 @@ public class BuildCode {
          output.println("if (needtocollect) checkcollect(&"+localsprefix+");");
       } else
        output.println("/* nop */");
-      return;
+      break;
 
     case FKind.FlatCheckNode:
       generateFlatCheckNode(fm, lb, (FlatCheckNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatFlagActionNode:
       generateFlatFlagActionNode(fm, lb, (FlatFlagActionNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatPrefetchNode:
       generateFlatPrefetchNode(fm,lb, (FlatPrefetchNode) fn, output);
-      return;
+      break;
 
     case FKind.FlatOffsetNode:
       generateFlatOffsetNode(fm, lb, (FlatOffsetNode)fn, output);
-      return;
+      break;
+
+    default:
+      throw new Error();
+    }
+
+    if( state.MLP ) {
+
+      CodePlan cp = mlpa.getCodePlan( fn );
+      if( cp != null ) {     
+
+       Set<VariableSourceToken> writeDynamic = cp.getWriteToDynamicSrc();      
+       if( writeDynamic != null ) {
+         
+       }
+      }
     }
-    throw new Error();
   }
 
   public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) {
index 0aaf5657dce1a9c2e6f2fc0f2c94859e19f1bbe0..285cf6b62bcbcb907642cd023f1e005adedeaf86 100644 (file)
@@ -38,8 +38,8 @@ SESErecord* mlpCreateSESErecord( int         classID,
   SESErecord* newrec = malloc( sizeof( SESErecord ) );
 
   newrec->classID          = classID;
-  newrec->instanceID       = instanceID;
-  newrec->childInstanceIDs = 0;
+  //newrec->instanceID       = instanceID;
+  //newrec->childInstanceIDs = 0;
   newrec->parent           = parent;
   newrec->childrenList     = createQueue();
   newrec->vars             = (SESEvar*) malloc( sizeof( SESEvar ) *
@@ -87,7 +87,8 @@ void mlpInit( int totalNumSESEs, int maxSESEage ) {
                                               maxSESEage            *
                                               totalNumSESEs
                                             );
-  current = rootsese;
+  //current = rootsese;
+  current = NULL;
 }
 
 
index c8af40c28a481c0632bc77a5b5b034a7d8b2a98b..ced7623003cdf683c56b992b8566c900374a68de 100644 (file)
@@ -6,8 +6,9 @@
 #include "Queue.h"
 
 
-// a forward delcaration for SESEvar
+// forward delcarations
 struct SESErecord_t;
+struct invokeSESEargs_t;
 
 
 typedef struct SESEvar_t {
@@ -43,6 +44,8 @@ typedef struct SESErecord_t {
   // are instances of one particular static code block
   int classID;
 
+
+  /* JUST USE POINTER TO SESErecord AS INSTANCE ID
   // not globally unqiue, but each parent ensures that
   // its children have unique identifiers, including to
   // the parent itself
@@ -50,6 +53,7 @@ typedef struct SESErecord_t {
 
   // used to give out IDs to children
   int childInstanceIDs;
+  */
 
   // pointers to SESEs directly above or below
   // in the heirarchy
index a8654e351a301cdd95bcdc66311f8781d025bf2b..85d87fe3aa1c0b1ab61240469e8b67efd46cb663 100644 (file)
@@ -23,9 +23,9 @@ public class Test {
     */
 
 
-    /*  ADD BACK IN LATER, TO TEST STALLS
+    //  ADD BACK IN LATER, TO TEST STALLS
     // shouldn't cause a stall
-    int z = x;
+    //int z = x;
 
     // stall and get values for y and z
     x = x + 1;
@@ -33,15 +33,15 @@ public class Test {
     // all of these should proceed without stall
     y = y + 1;
     x = x + 1;
-    z = z + 1;
-    */
+    //z = z + 1;
+    
 
     // see that values from sese fi are
     // forwarded to this sibling
-    sese fo {
-      // expecting x=3, y=3
-      System.out.println( "x="+x+", y="+y );
-    }
+    //sese fo {
+    // expecting x=5, y=4
+    System.out.println( "x="+x+", y="+y );
+      //}