From dd507ccd873fc7e44d2aeba733b6202fff72b881 Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 25 Aug 2009 21:32:41 +0000 Subject: [PATCH] method call support works for small programs, bigger ones hang --- Robust/src/Analysis/MLP/MLPAnalysis.java | 21 +++++++-- Robust/src/IR/Flat/BuildCode.java | 14 ++++-- Robust/src/Runtime/mlp_runtime.c | 4 +- Robust/src/Runtime/mlp_runtime.h | 3 ++ Robust/src/Runtime/workschedule.c | 2 +- Robust/src/Tests/mlp/regression/test.java | 56 ++++++++++------------- Robust/src/Tests/mlp/tinyTest/test.java | 37 +++++++++------ 7 files changed, 82 insertions(+), 55 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 531795b6..49a8b498 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -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 diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index e5610635..cda73725 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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(); diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index f9860130..637558d1 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -10,12 +10,14 @@ #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 ) { diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 71fb7727..3f7ca184 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -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 diff --git a/Robust/src/Runtime/workschedule.c b/Robust/src/Runtime/workschedule.c index 08bb5dfb..b1e29c02 100644 --- a/Robust/src/Runtime/workschedule.c +++ b/Robust/src/Runtime/workschedule.c @@ -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 ); diff --git a/Robust/src/Tests/mlp/regression/test.java b/Robust/src/Tests/mlp/regression/test.java index ee8cf6f1..6ceb129f 100644 --- a/Robust/src/Tests/mlp/regression/test.java +++ b/Robust/src/Tests/mlp/regression/test.java @@ -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; - } - } - */ } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 8677ea17..23c7e04c 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -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 { -- 2.34.1