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;
}
} 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
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 );");
}
} 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
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()+";");
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\" );");
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
}
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();
#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 ) {
// 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
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 );
-public class Foo {
- int f;
- public Foo() {}
-}
-
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 ) {
System.out.println( "sum of integers 0-"+i+" is "+sum );
}
}
-
- /*
- public static void setTo3( Foo foo ) {
- sese func {
- foo.f = 3;
- }
- }
- */
}
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
//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 {