From ef63f6bd37f5cf9f8989ee5641476eb241649ee9 Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 16 Jun 2009 21:47:49 +0000 Subject: [PATCH] more work on mlp system --- Robust/src/Analysis/MLP/CodePlan.java | 49 +++++++------ Robust/src/IR/Flat/BuildCode.java | 95 ++++++++++++++----------- Robust/src/Runtime/mlp_runtime.c | 7 +- Robust/src/Runtime/mlp_runtime.h | 6 +- Robust/src/Tests/mlp/tinyTest/test.java | 16 ++--- 5 files changed, 100 insertions(+), 73 deletions(-) diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index d5df9748..ed90f2c2 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -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 writeToDynamicSrc; + public CodePlan() { - seseToIssue = null; + writeToDynamicSrc = null; } - - public void setSESEtoIssue( FlatSESEEnterNode sese ) { - seseToIssue = sese; + public void setWriteToDynamicSrc( + Set writeToDynamicSrc + ) { + this.writeToDynamicSrc = writeToDynamicSrc; } - public FlatSESEEnterNode getSESEtoIssue() { - return seseToIssue; + public Set 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 vstItr = writeToDynamicSrc.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + s += ", "+vst; + } + + s += "]"; } return s; diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 0df10c51..1f0dc5c7 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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 "); outmethod.println("#include "); 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 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 writeDynamic = cp.getWriteToDynamicSrc(); + if( writeDynamic != null ) { + + } + } } - throw new Error(); } public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) { diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index 0aaf5657..285cf6b6 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -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; } diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index c8af40c2..ced76230 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -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 diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index a8654e35..85d87fe3 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -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 ); + //} -- 2.34.1