method call support works for small programs, bigger ones hang
authorjjenista <jjenista>
Tue, 25 Aug 2009 21:32:41 +0000 (21:32 +0000)
committerjjenista <jjenista>
Tue, 25 Aug 2009 21:32:41 +0000 (21:32 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h
Robust/src/Runtime/workschedule.c
Robust/src/Tests/mlp/regression/test.java
Robust/src/Tests/mlp/tinyTest/test.java

index 531795b63fa99fa5c24ad19e33065d0e61dedf8a..49a8b498fc80013a0213d9f99f16804692d3a747 100644 (file)
@@ -812,6 +812,22 @@ public class MLPAnalysis {
       notAvailSet.addAll( liveTemps );
     } break;
 
+    case FKind.FlatMethod: {
+      notAvailSet.clear();
+    }
+
+      /*
+    case FKind.FlatCall: {
+      FlatCall         fc = (FlatCall) fn;
+      MethodDescriptor md = fc.getMethod();
+      FlatMethod       fm = state.getMethodFlat( md );
+      for( int i = 0; i < fm.numParameters(); ++i ) {
+       TempDescriptor param = fm.getParameter( i );
+       notAvailSet.remove( param );
+      }
+    } break;
+      */
+
     case FKind.FlatOpNode: {
       FlatOpNode fon = (FlatOpNode) fn;
 
@@ -1092,10 +1108,7 @@ public class MLPAnalysis {
          }                      
 
        } else {
-         // the other case for srcs is READY from a parent, however
-         // since we are only examining variables that come from
-         // children tokens, this should never occur
-         assert false;
+         // the other case for srcs is READY, so do nothing
        }
 
        // assert that everything being stalled for is in the
index e56106359c752fe0456a9f3e9c11afe7ead90795..cda737257a1f86c6bc5a68fd650e6f26e7f30804 100644 (file)
@@ -286,7 +286,7 @@ public class BuildCode {
     outmethod.println("  int i;");
 
     if (state.MLP) {
-      outmethod.println("  pthread_once( &mlpOnceObj, mlpInitOncePerThread );");
+      //outmethod.println("  pthread_once( &mlpOnceObj, mlpInitOncePerThread );");
       outmethod.println("  workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );");
     }
 
@@ -2849,7 +2849,8 @@ public class BuildCode {
     } else if( fsen.getParent() != null ) {
       output.println("     SESEcommon* parentCommon = &("+paramsprefix+"->common);");
     } else {
-      output.println("     SESEcommon* parentCommon = (SESEcommon*) peekItem( seseCallStack );");
+      //output.println("     SESEcommon* parentCommon = (SESEcommon*) peekItem( seseCallStack );");
+      output.println("     SESEcommon* parentCommon = seseCaller;");
     }
 
     // before doing anything, lock your own record and increment the running children
@@ -2865,7 +2866,7 @@ public class BuildCode {
                           fsen.getSESErecordName()+" ) );");
 
     // and keep the thread-local sese stack up to date
-    output.println("     addNewItem( seseCallStack, (void*) seseToIssue);");
+    //output.println("     addNewItem( seseCallStack, (void*) seseToIssue);");
 
     // fill in common data
     output.println("     seseToIssue->common.classID = "+fsen.getIdentifier()+";");
@@ -3002,6 +3003,7 @@ public class BuildCode {
 
     String com = paramsprefix+"->common";
 
+    /*
     // take yourself off the thread-local sese call stack
     output.println("   if( isEmpty( seseCallStack ) ) {");
     output.println("     printf( \"Error, sese call stack is empty.\\n\" );");
@@ -3011,6 +3013,7 @@ public class BuildCode {
     output.println("     printf( \"Error, sese call stack mismatch.\\n\" );");
     output.println("     exit( -1 );");
     output.println("   }");
+    */
 
     // this SESE cannot be done until all of its children are done
     // so grab your own lock with the condition variable for watching
@@ -3135,6 +3138,11 @@ public class BuildCode {
   }
 
   private void generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) {
+
+    if( state.MLP ) {
+      output.println("     seseCaller = (SESEcommon*)"+paramsprefix+";");
+    }
+
     MethodDescriptor md=fc.getMethod();
     ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md);
     ClassDescriptor cn=md.getClassDesc();
index f9860130c22bab1245808fcb3973c3a0a17bf31c..637558d119482190f8017ae03ac2a39e62481ae6 100644 (file)
 #include "workschedule.h"
 
 
-
+/*
 __thread struct Queue* seseCallStack;
 __thread pthread_once_t mlpOnceObj = PTHREAD_ONCE_INIT;
 void mlpInitOncePerThread() {
   seseCallStack = createQueue();
 }
+*/
+__thread SESEcommon_p seseCaller;
 
 
 void* mlpAllocSESErecord( int size ) {
index 71fb7727f670cbe46ac655b054600ce26c5689fd..3f7ca184470b7b783f414b63d973ae8302a54d3f 100644 (file)
@@ -53,9 +53,12 @@ typedef struct SESEcommon_t {
 
 // a thread-local stack of SESEs and function to
 // ensure it is initialized once per thread
+/*
 extern __thread struct Queue* seseCallStack;
 extern __thread pthread_once_t mlpOnceObj;
 void mlpInitOncePerThread();
+*/
+extern __thread SESEcommon_p seseCaller;
 
 
 // simple mechanical allocation and 
index 08bb5dfbde1dbab1bb47db5c0b37b06af218f564..b1e29c02bd077c88df5bd695a455222d0339ecce 100644 (file)
@@ -155,7 +155,7 @@ void* workerMain( void* arg ) {
   void* workUnit;
 
   // make sure init mlp once-per-thread stuff
-  pthread_once( &mlpOnceObj, mlpInitOncePerThread );
+  //pthread_once( &mlpOnceObj, mlpInitOncePerThread );
 
   // all workers wait until system is ready
   pthread_mutex_lock  ( &systemLock );
index ee8cf6f17e41d3d842550ed493d482c968343f05..6ceb129f5691e98286937683fd758d44a6352ea8 100644 (file)
@@ -1,8 +1,3 @@
-public class Foo {
-  int f;
-  public Foo() {}
-}
-
 
 public class Test {
 
@@ -10,45 +5,52 @@ public class Test {
         
     int x = Integer.parseInt( args[0] );
 
+    doSomeWork( x );
+  }
 
 
-    //int y = Integer.parseInt( args[1] );
-
+  public static void doSomeWork( int x ) {
     for( int i = 0; i < x; ++i ) {
-
       sese calc {
        int sum = 0;
        for( int j = 0; j <= i; ++j ) {
-         sum = sum + j;
+         sum = calculateStuff( sum, 1, 0 );
        }
       }
-
       if( i % 2 == 0 ) {
        sese change {
          for( int k = 0; k < i*2; ++k ) {
-           sum = sum + 1;          
+           sum = calculateStuff( sum, k, 1 );
          }
          sum = sum + 1;
        }       
-
-       sese changeAgain {
-         for( int l = 0; l < 3; ++l ) {
-           sum = sum / 2;
-         }
+       
+       for( int l = 0; l < 3; ++l ) {
+         sum = calculateStuff( sum, 2, 2 );
        }
       }
-
       sese prnt {
        mightPrint( x, i, sum );
       }
-
     }
+  }
 
-
-    
-    //Foo foo = new Foo();
-    //foo.f = x;
-    //setTo3( foo );
+  public static int calculateStuff( int sum, int num, int mode ) {
+    int answer;
+    if( mode == 0 ) {
+      sese mode1 {
+       answer = sum + num;
+      }
+    } else if( mode == 1 ) {
+      sese mode2 {
+       answer = sum + (num/2);
+      }
+    } else {
+      sese mode3 {
+       answer = sum / num;
+      }
+    }
+    return answer;
   }
 
   public static void mightPrint( int x, int i, int sum ) {
@@ -56,12 +58,4 @@ public class Test {
       System.out.println( "sum of integers 0-"+i+" is "+sum );
     }
   }
-
-  /*
-  public static void setTo3( Foo foo ) {
-    sese func {
-      foo.f = 3;
-    }   
-  }
-  */
 }
index 8677ea172327face17cf071da14970c94e5bebb5..23c7e04cdc982eaeb24e197a9271d0a171c3ccf3 100644 (file)
@@ -11,21 +11,7 @@ public class Test {
     int x = Integer.parseInt( args[0] );
     //int y = Integer.parseInt( args[1] );
 
-    for( int i = 0; i < x; ++i ) {
-
-      sese calc {
-       int sum = 0;
-       for( int j = 0; j <= i; ++j ) {
-         sum = sum + j;
-       }
-      }
-
-      sese prnt {
-       mightPrint( x, i, sum );
-      }
-
-    }
-
+    doTheTest( x );
 
     // just for testing root's ability to
     // realize a single exit after all returns
@@ -40,6 +26,27 @@ public class Test {
     //setTo3( foo );
   }
 
+  public static void doTheTest( int x ) {
+    
+    sese wrapper {
+
+      for( int i = 0; i < x; ++i ) {
+       sese calc {
+         int sum = 0;
+         for( int j = 0; j <= i; ++j ) {
+           sum = sum + j;
+         }
+       }
+       
+       sese prnt {
+         mightPrint( x, i, sum );
+       }
+      }
+      
+    }
+
+  }
+
   public static void mightPrint( int x, int i, int sum ) {    
     if( i == x - 1 ) {
       sese output {