From fed3392c08f5a18a592e76b69826ef1985d7fe7a Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 26 May 2009 18:23:53 +0000 Subject: [PATCH] Stable, not functional. Builds a switch case for unique SESE class invocation, including whether it has the root SESE for a parent or not --- Robust/src/Analysis/MLP/MLPAnalysis.java | 2 +- Robust/src/IR/Flat/BuildCode.java | 32 ++++++++++++++++++------ Robust/src/Runtime/mlp_runtime.c | 14 +++++++++-- Robust/src/Runtime/mlp_runtime.h | 5 ++++ 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 74edb3fe..1848d470 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -142,7 +142,7 @@ public class MLPAnalysis { //System.out.println( fmMain.printMethod( livenessRootView ) ); //System.out.println( fmMain.printMethod( variableResults ) ); //System.out.println( fmMain.printMethod( notAvailableResults ) ); - System.out.println( "CODE PLANS\n"+fmMain.printMethod( codePlans ) ); + //System.out.println( "CODE PLANS\n"+fmMain.printMethod( codePlans ) ); } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index e02ff92f..a58b3622 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -290,6 +290,9 @@ public class BuildCode { outmethod.println(" ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i-1]=newstring;"); outmethod.println(" }"); + if (state.MLP) { + outmethod.println(" mlpInit();"); + } MethodDescriptor md=typeutil.getMain(); ClassDescriptor cd=typeutil.getMainClass(); @@ -354,7 +357,6 @@ public class BuildCode { outmethod.println("pthread_exit(NULL);"); outmethod.println("}"); - } /* This method outputs code for each task. */ @@ -1511,8 +1513,15 @@ public class BuildCode { PrintWriter outmethod ) { - outmethodheader.println("void invokeSESEmethod( int classID, struct SESErecord* record );"); - outmethod.println( "void invokeSESEmethod( int classID, struct SESErecord* record ) {"); + outmethodheader.println("void invokeSESEmethod( int classID, struct SESErecord* invokee, struct SESErecord* parent );"); + outmethod.println( "void invokeSESEmethod( int classID, struct SESErecord* invokee, struct SESErecord* parent ) {"); + + // use this info in the invocation cases to decide whether + // to gather SESE variables from a parent SESE record, or + // if parent is root, from noraml temps + outmethod.println( " char parentIsRoot = (parent == NULL);"); + + // generate a case for each SESE class that can be invoked outmethod.println( " switch( classID ) {"); outmethod.println( " "); for(Iterator seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) { @@ -1523,6 +1532,8 @@ public class BuildCode { outmethod.println( " break;"); outmethod.println( ""); } + + // default case should never be taken, error out outmethod.println( " default:"); outmethod.println( " printf(\"Error: unknown SESE class ID in invoke method.\\n\");"); outmethod.println( " exit(-30);"); @@ -1544,7 +1555,12 @@ public class BuildCode { ParamsObject objectparams = (ParamsObject)paramstable.get(bogusmd); // first copy SESE record into param structure - + output.println(" if( parentIsRoot ) {"); + output.println(" "); + output.println(" "); + output.println(" } else {"); + output.println(" "); + output.println(" }"); // then invoke the sese's method output.print(" "+cn.getSafeSymbol()+bogusmd.getSafeSymbol()+"_"+bogusmd.getSafeMethodDescriptor()); @@ -1552,15 +1568,17 @@ public class BuildCode { // why doesn't this work? //output.print("("+cn.getSafeSymbol()+bogusmd.getSafeSymbol()+"_"+bogusmd.getSafeMethodDescriptor()+paramsprefix+")"); - output.print("(struct "+cn.getSafeSymbol()+bogusmd.getSafeSymbol()+"__params*)"); - output.print("&(record->paramStruct)"); + // first argument is parameter structure + output.print("(struct "+cn.getSafeSymbol()+bogusmd.getSafeSymbol()+"__params*)"); + output.print("&(invokee->paramStruct)"); + // other arguments are primitive parameters for(int i=0; ivars["+i+"].sesetype_"+type.toString()); + output.print(", invokee->vars["+i+"].sesetype_"+type.toString()); } output.println(");"); diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index 57604a98..0a42e27d 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -4,11 +4,21 @@ #include "Queue.h" -struct Queue* issued; +static struct Queue* issued; + + +// each core should have a current SESE +static struct SESErecord* current; void mlpInit() { - issued = createQueue(); + issued = createQueue(); + current = NULL; +} + + +struct SESErecord* mlpGetCurrent() { + return current; } diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 5480ad2f..2830fd2c 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -39,6 +39,9 @@ struct SESEvar { // a statically or dynamically known SESE // to gather the variable's value from + // if source==NULL it indicates the root + // SESE, which has no record, just normal + // temp names struct SESErecord* source; unsigned int index; }; @@ -67,6 +70,8 @@ struct SESErecord { void mlpInit(); +struct SESErecord* mlpGetCurrent(); + void mlpIssue ( struct SESErecord* sese ); void mlpStall ( struct SESErecord* sese ); void mlpNotifyExit( struct SESErecord* sese ); -- 2.34.1